0

I have a Client and a server application, very simple code and it is working.
But with the client, I can send one time a message, do I want another, it does not appear at the server. No response, nothing.

Here is my code:

Client:

procedure TForm1.FormCreate(Sender: TObject);
begin
  TcpClient1.RemotePort := '23';
  TcpClient1.RemoteHost := '127.0.0.1';
  TcpClient1.Active := True;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  TcpClient1.Active := False;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if TcpClient1.Active then
    TcpClient1.Sendln(Edit1.Text)
  else
    ShowMessage('Connection lost..');
end;

end.

Server:

procedure TForm1.FormCreate(Sender: TObject);
begin
  TcpServer1.LocalPort := '23';
  TcpServer1.Active := True;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  TcpServer1.Active := False;
end;

procedure TForm1.TcpServer1Accept(Sender: TObject;
  ClientSocket: TCustomIpClient);
begin
  Memo1.Lines.add(ClientSocket.Receiveln);
  ShowMessage ('I get data!')
end;

end.

So anybody have comments or suggestions? (I do not ask a complete out of the box solution, I want to get to a higher level ;) )

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by kvdd
0

OK, the showmessage is a dialogbox, all processing in your app stops when thats sent. So it probably does "eat" the second message if you click twice.

0

Thanks for the answer. I have searched around on the internet after posting this new thread, and saw that Indy is the way to go. I have now a working Client/Server very funny! :)

-- I use Delphi 7 as IDE and Indy 9 that comes with.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.