Recent

Author Topic: lNet: Disconnect after SendMessage  (Read 1761 times)

S-Man

  • Newbie
  • Posts: 2
lNet: Disconnect after SendMessage
« on: August 27, 2014, 06:38:03 pm »
Hi,

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

The code looks like:
Code: [Select]
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:

Code: [Select]
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

  • Newbie
  • Posts: 2
Re: lNet: Disconnect after SendMessage
« Reply #1 on: August 28, 2014, 12:17:37 am »
Got the solution:

The SendMessage comes too fast. It has to called in OnConnect.

Greets S-Man

 

TinyPortal © 2005-2018