PDA

Click to See Complete Forum and Search --> : Closing a WinSock connection


rockies1
Jan 5th, 2001, 10:02 AM
I have been able to connect to a server using Winsock, and I can send & receive data just fine.

The problem, however, is that after the remote host closes the connection, my Winsock.State goes to 8, Closing, but never gets to 0, Closed.

Am I missing something? I can't force the state to closed, but if it never actually closes, my program errors out when I try to re-connect.

Any help is appreciated.

Thanks!!

ccoder
Jan 5th, 2001, 03:21 PM
Are you specifying the LocalPort? If so, get rid of it and let the control pick one for you.

If you open a CMD window and run NETSTAT after each connect and disconnect, you will probably see the client's connection go to state FIN_WAIT_2 after you close the session.

By not specifying the LocalPort, a different (and available) port will be used on each connect request.