Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: TCP client/server
| Subject: | Re: TCP client/server |
| Posted by: | "Richard Bibby" (richard.bib..@profdoc.se) |
| Date: | Tue, 6 Jun 2006 12:17:17 |
Hej,
Thanks for all the interesting chat, but I am not sure I am any the wiser.
I would like to look at the demos and tutorials... where are they?
However a bit more information...
Currently I have client and server components in the same application (while
I am testing). Also the dTCPServer1Execute(AThread: TIdPeerThread) event
executes TWICE for the single WriteLn in the client, and its the second time
that I get the exception.
Any idea why the this should happen. Perhaps I have not coded the server
correctly?
/Richard
"Richard Bibby" <richard.bibby@profdoc.se> skrev i meddelandet
news:44848d05$1@newsgroups.borland.com...
>
>
> 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