Thank you Kaj. I did the same thing and put accept() in a while loop. Unfortranetly, once the client was closed, it can not reconnect to the server any more. This is the pseudo code of my question. Server Side: SOCKET Socket; Socket = socket(AF_INET, SOCK_STREAM, 0); SOCKADDR_IN SockAddr; assign IP and port to SockAddr; bind the socket; listen(Socket, 1); SOCKET ...