i have 2 forms 1 for server another for client after droping ttcpserver on server form and setting its localhost property to 127.0.0.1 and localport property to 55555 and Active property to true i wrote a button1(sendtextbutton) onclick event handler:
procedure TForm2.Button1Click(Sender: TObject);
begin
TcpServer1.Sendln('message');
end;
then on client form i droped 1 ttcpclient 1 label 2 buttons, set clients remote host property to 127.0.0.1 and remote port to 55555 ,wrote an event handler for connectbutton(button1) :
procedure TForm2.Button1Click(Sender: TObject);
begin
try
TcpClient1.Active := true;
except
showmessage('error');
end;
end;
wrote an onconnect event for ttcpclient : procedure TForm2.TcpClient1Connect(Sender: TObject);
begin
Label1.Caption := 'connected!';
end;
and then finally an onrecieve event hadler for ttcpclient:
procedure TForm2.TcpClient1Receive(Sender: TObject; Buf: PAnsiChar;
var DataLen: Integer);
begin
Label1.caption := TcpClient1.Receiveln();
end;
my client programs caption was supposed to change to 'message'(after i connect and click button on my server form) but it doest am i doing it the wrong way? if yes then how to do it i am trying to send a text message from server to client(Yes a reverse connection!)
note: i am new to world of programming
please help!