
May 16th, 2003, 10:35 AM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Re: Address in Use "Winsock"
Quote: Originally posted by rizbaig_pk
Hi,
I used winsock my chat application on form_unload i close my winsock by winsock.close but when i run again that program it show the error "Address in Use" . So, any person plz give me full detail to how completely close a connection....
Waiting for response.
Riz. |
This is one of the reasons that I prefer not to use the winsock control when I need to do tcpip communications. I would highly recommend using direct calls to the winsock API, then you could program around the problem you are having. Here it is in a nutshell.
When you tell your winsock control to close the connection, it immediately executes a shutdown command, followed by a close. Berkley Sockets (which is what the windows interface to tcpip is based on) calls for sockets that have ACCEPTED another connection, and that have been closed without recieving notification that the other side has finished sending information will linger on your system for approximately 3 minutes. While this is still ok if you are using the API to listen for connections, the winsock control doesnt like this and wont let you use the port again.
This may be a little overkill for your needs, but if you want a really robust chat application, the winsock control just isnt going to cut the mustard.
|