I make an application with winsock that send and retrive information from server application. You must configure a server application to listen several requirements, so you will have problem when another application ask to server o client close and server continue running.
You must control the packets sended too, in order to keep open conection at last packet was received.
See data_arrival, connect and close event, and include Doevents follow SendData (it's a bus of Winsock)
Good Luck !!