SO_RCVTIMEO in setsockopt

I need a receive time out in a read() function because read() hangs up my
process until a message be received.

I´m trying to use like this…
,
struct timeval time_out ;
memset(time_out,0,sizeof(time_out));
time_out.tv_sec=2L;
time_out.tv_usec=0L;
setsockopt ( mysock, SOL_SOCKET, SO_RCVTIMEO , &time_out ,
&sizeof(time_out) ) ;
,

But read() or recv() functions still getting a time out in about 1 minute
and 15 seconds.

How does it works ? And how can I trace the EWOULDBLOCK error ?

Tx,
Ricardo Az : ricardoaz@terra.com.br

Ricardo Az wrote:

I need a receive time out in a read() function because read() hangs up my
process until a message be received.

I´m trying to use like this…
,
struct timeval time_out ;
memset(time_out,0,sizeof(time_out));
time_out.tv_sec=2L;
time_out.tv_usec=0L;
setsockopt ( mysock, SOL_SOCKET, SO_RCVTIMEO , &time_out ,
&sizeof(time_out) ) ;
,

But read() or recv() functions still getting a time out in about 1 minute
and 15 seconds.

How does it works ? And how can I trace the EWOULDBLOCK error ?

Which stack are you using ? The tiny stack doesn’t support SO_RCVTIMEO
according to the docs.

Also, you aren’t actually passing the address of the sizeof(time_out)
are you (would this even compile ?)

In the thread SO_RCVTIMEO beginning Tue, 23 Jul 2002 22:14:21 Sean identified
this as a bug that has been fixed internally. Until the fix becomes
available you can make do by using TimerTimeout() just before your read();
note, however, that on a timeout you’ll get error EINTR instead of ETIMEDOUT.

Murf

Ricardo Az wrote:

I need a receive time out in a read() function because read() hangs up my
process until a message be received.

I´m trying to use like this…
,
struct timeval time_out ;
memset(time_out,0,sizeof(time_out));
time_out.tv_sec=2L;
time_out.tv_usec=0L;
setsockopt ( mysock, SOL_SOCKET, SO_RCVTIMEO , &time_out ,
&sizeof(time_out) ) ;
,

But read() or recv() functions still getting a time out in about 1 minute
and 15 seconds.

How does it works ? And how can I trace the EWOULDBLOCK error ?

Tx,
Ricardo Az : > ricardoaz@terra.com.br