unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, scktcomp, StdCtrls;
type
TForm1 =
class(TForm)
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
FClient:TClientSocket;
procedure ClientRead(Sender:TObject; Socket: TCustomWinSocket);
procedure ClientError(Sender:TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ClientError(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
showmessage(syserrormessage(Errorcode));
end;
procedure TForm1.ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.add(socket.ReceiveText);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Fclient:=TClientSocket.Create(self);
FClient.Address:='
127.0.0.1';
FClient.Port:=5000;
FClient.ClientType:=ctNonBlocking;
FClient.OnRead:=ClientRead;
FClient.OnError:=ClientError;
FClient.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FClient.Socket.SendText(Edit1.text);
end;
end.