Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: Closing a TIdTCPClient Connection
| Subject: | Re: Closing a TIdTCPClient Connection |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 28 Mar 2006 03:53:44 |
"Dennis" <marianndkc@home3.gvdnet.dk> wrote in message
news:442915fb$1@newsgroups.borland.com...
> Before closing my application I call Disconnect and Free, but when
> I restart the application I cannot connect again. I get a "Socket error
> #10048 - Address already in use" exception.
The OS keeps a socket open for a period of time after the application closes
it, in case unexpected data arrives on the connection. Typically, the only
time you can ever get that error on the client side is if you are using the
BoundIP and BoundPort properties. Are you using them?
If you are using them, then the only workaround to the error is to enable
the SO_REUSEADDR option on new sockets that use the same IP/Port and earlier
sockets that the OS still has opened. However, TIdTCPClient does not
provide access to that, since it has to be applied at the time the socket is
created but before it is bound to any network adapter. If you need that,
then you will have to alter Indy's source code to add the logic in manually,
and then recompile Indy.
> What is it that I fail to do?
Nothing.
Gambit