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

www.cryer.info
Managed Newsgroup Archive

Re: TCP client/server

Subject:Re: TCP client/server
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Mon, 5 Jun 2006 16:15:31

"Jamie Dale" <j.dale@turboz.net> wrote in message
news:4484b8f4@newsgroups.borland.com...

> I was only trying to show another way of getting around the
> "connection closed gracefully" thing. I know what a pig it can be.

If you are having to implement workarounds all the time, then you are
probably not using it the way it was designed to be used to begin with.  If
you keep getting "Connection closed gracefully" exceptions, then you need to
take a deeper look at why you are accessing the sockets after they have been
closed.

> Besides, Richard stated that he currently disconnects the client
> FROM the SERVER.

He's disconnecting from both ends.  Which is not technically wrong.  But
under most situations, the server code should not be calling Disconnect().
Only the client should be.  TIdTCPServer will clean up the socket when the
owning thread is terminated after the client disconnects.

> Therefore, maybe he will actually find my tip useful?

The only thing you said that applies to his situation is something that he
was already doing - calling Disconnect() on the server side.  Calling
ReadLn() on the client side does not help the situation.  And you should not
be using try..except blocks just to hide arbitrary exceptions without good
cause anyway.  That just serves to hide errors in your own code that leads
to the exceptions being thrown in the first place.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive