hi alok, thanks a lot for ur reply, but eventually i figured out my problem was not related with opening or closing but what i am using is ASyncSockets which are by default NON blocking sockets as a results the connection closes automatically if there is no buffer recieved so i used CSocket class ie a Blocking Socket class as a result untill unless the Buffer is recieved the connection is alive. thanks a lot again