Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : TCP client/server

www.cryer.info
Managed Newsgroup Archive

TCP client/server

Subject:TCP client/server
Posted by:"Richard Bibby" (richard.bib..@profdoc.se)
Date:Mon, 5 Jun 2006 21:59:02

Hej,

Previously I posted a thread about UDP and was pointed in the direction of
using the idTCPClient and idTCPServer components.

I have started to use them but have a question.

My client app wants to send a message, but does not expect any response.  I
use the following code:

    try
      IdTCPClient.Connect ;
      try
        IdTCPClient.WriteLn( 'My message' );
      finally
        IdTCPClient.Disconnect ;
      end ;
    except
      Showmessage( 'Could not connect!' );
    end ;

On the server side I have the following code in the IdTCPServerExecute
event:


    ....
     myString :=  AThread.Connection.ReadLn ;
   .. do something

      AThread.Connection.Disconnect;


Is this the correct way to handle it?  I get a 'Connection closed
gracefully' exception on the client side.  Am I doing something wrong or
should I ignore the exception because I see that I am getting the data.

/Richard

Replies:

www.cryer.info
Managed Newsgroup Archive