I have created a receiving socket, using nanomsg library and trying to nn_recv() a message as code below shows :
recv_bytes = nn_recv ( socket_id, &buf, NN_MSG, 0 );
when the recv_bytes was < 0, I do following :
if ( recv_bytes <= 0) {
struct nn_polld pfd[1] ;
pfd[0].fd = socket_id;
pfd[0].events = NN_POLLIN;
rc = nn_poll ( pfd, 1, 2000 );
if ( rc == 0 ) {
printf ( "Timeout!" );
// exit (1);
}
if ( rc == -1 ) {
printf ( "Error!" );
// exit (1);
}
if ( pfd [0].revents & NN_POLLIN ) {
printf ( "Message can be received from s1!" );
// exit (1);
}
}
I don't see Error! text at all, I always see other prints, but not receiving any messages until I rebind to socket.
I wanted to know if there is any way that i can get error through NN_POLL and reconnect/bind again. Problem is I don't want to do it randomly upon a timer.
Please suggest.
I am unable to receive messages from the end-point, when one of the end-stations got closed. If I know nanomsg socket has gone bad, then I can rebind but not getting any error and at the same time no messages are received from other end stations too.