Reusing socket descriptor on connection failure
In my client code, I am following these steps to connect to a socket: Creating a socket sockDesc = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) Connecting it (retry for 'x' time in case of failure) connect(sockDesc, (sockaddr *) &destAddr, sizeof(destAddr)) (After filling the destAddr fields) Using the socket for send()/recv() operation: send(sockDesc, buffer, bufferLen, 0) recv(sockDesc, buffer, bufferLen, 0) close() the socket descriptor and exit close(sockDesc) If during send()/recv() the connection breaks, I found that I could connect by returning to step 2. Is this solution okay? should I cl
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.