reconnect a disconnected client socket
Is it possible to reconnect an already disconnected socket without having to cre开发者_如何转开发ate a new socket FD?
Example:
int s = socket();
connect(s,...);
....
socket disconnects
....
connect(s,...); <-------
According to the manpage, "Generally, stream sockets may successfully connect() only once; datagram sockets may use connect() multiple times to change their association." So if your socket is a TCP socket, the answer is "probably not"; if it's a UDP socket, the answer is "probably".
精彩评论