0

i've a problem. I am using a TLTCPComponent named "Client".

The code looks like:

procedure TForm1.Create(Sender: TObject);
begin
   Client.Connect(ServerIP, Port); //ServerIP and Port are given...
   Client.SendMessage('SomeText');
end;

The server application is getting the connection. Then it receives a '' string and receives a disconnect from the client.

If I try following:

procedure TForm1.Create(Sender: TObject);
begin
   Client.Connect(ServerIP, Port); //ServerIP and Port are given...
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Client.SendMessage('SomeText');
end;

everything is alright. The server gets the connection from the client. And if I send text with the button the connection stays open.

The problem is now: Why does the connection close if I send text right after the opening?

Greets and thanks, S-Man

S-Man
  • 22,521
  • 7
  • 40
  • 63

1 Answers1

0

The Solution: The SendMessage comes too fast. It has to called in the OnConnect method.

S-Man
  • 22,521
  • 7
  • 40
  • 63