The code I am giving you is based on what I think you want to do. You have two programs. One is a client and the other is a server. The client connects to the server. Client then sends some data. When data has been sent your client's _SendComplete event is entered. There you close the client's sockets. The server get's the data but does not close his socket. If he does you will need to re-open it again before you press the cmdSend button After client closes his socket and the server does not you now can press the cmdSend button again. If this is what you are doing then the code I posted works.