Reputation: 407
I have the following code:
Client side:
n=recv(sock,buf,1200,NULL);
Server side:
shutdown(sockk,SD_BOTH);
The problem is, the client side recv
is returning 0, meaning graceful shutdown. I need it to return -1 (I can't change the client side, I need to adapt my code to it.)
What can i do to cause it returning -1?
Upvotes: 0
Views: 1403
Reputation: 407
I figured it out.
Set the socket with SO_LINGER
and thus cause an abortive shutdown.
Now it returns -1
after shutdown()
.
Upvotes: 2
Reputation: 7034
Do not call shutdown() or close() from server, and you can then send some signal to the client side process. So recv() call will return -1 with errno set with EINTR. Hope this helps.
But I suggest you should not adopt such coding practice. recv() can return 0, +ve number and -1. Its good to handle all these cases.
Upvotes: 0