ClientSocket:=TClientSocket. Create (nil);
ClientSocket. OnRead:=MySocketRead;
Procedure MySocketRead (Sender: TObject; Sockets: TCustomWinSocket);
The begin
Why not receive information here??
end;
Connection is normal, also send data the server end, the client this is what information is received,
How can I define the events and Clientsocket binding together???????
CodePudding user response:
unit MainFormUnit;
Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ScktComp;
Type
TMainForm=class (TForm)
MmoLog: TMemo;
BtnRequest: TButton;
EdtUrl: TEdit;
Procedure FormCreate (Sender: TObject);
Procedure FormDestroy (Sender: TObject);
Procedure btnRequestClick (Sender: TObject);
Private
FClient: TClientSocket;
Procedure OnRead (Sender: TObject; Sockets: TCustomWinSocket);
Procedure OnConnect (Sender: TObject; Sockets: TCustomWinSocket);
Public
{Public declarations}
end;
Var
MainForm: TMainForm;
Implementation
{$R *. DFM}
Procedure TMainForm. FormCreate (Sender: TObject);
The begin
FClient:=TClientSocket. Create (nil);
FClient. OnRead:=OnRead;
FClient. OnConnect:=OnConnect;
end;
Procedure TMainForm. FormDestroy (Sender: TObject);
The begin
FClient. Free;
end;
Procedure TMainForm. OnRead (Sender: TObject; Sockets: TCustomWinSocket);
The begin
MmoLog. Lines. The Add (Socket. ReceiveText);
end;
Procedure TMainForm. BtnRequestClick (Sender: TObject);
The begin
FClient. Host:=edtUrl. Text;
FClient. Port:=80;
FClient. Open;
end;
Procedure TMainForm. OnConnect (Sender: TObject; Sockets: TCustomWinSocket);
The begin
Socket. SendText (' GET/HTTP/1.1 # 13 # 10. 'Host:' + edtUrl Text + # 13 # 10 # 13 # 10);
end;
End.
Write an example, look at yourself,
CodePudding user response:
Port? Didn't connect, only two lines of code can doCodePudding user response:
Do not understand the code, looking forward to,,,,CodePudding user response:
The To pathletboy,CodePudding user response: