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 ;) )

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.