April 22nd, 2003, 06:55 AM
Address in Use "Winsock"
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.
April 24th, 2003, 07:42 AM
are you using an array of winsock controls ( most chat programs use array of controls that are loaded. I so u must unload all , or close all such controls . Again what address are u using . The address must not be any of the reserved address
Re: Address in Use "Winsock"
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.