SO_RCVTIMEO in setsockopt

bridged with qdn.public.ddk.network
Post Reply
Ricardo Az

SO_RCVTIMEO in setsockopt

Post by Ricardo Az » Thu Oct 10, 2002 12:31 pm

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

Rennie Allen

Re: SO_RCVTIMEO in setsockopt

Post by Rennie Allen » Thu Oct 10, 2002 12:31 pm

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 ?)

John A. Murphy

Re: SO_RCVTIMEO in setsockopt

Post by John A. Murphy » Fri Oct 11, 2002 2:15 am

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

Post Reply

Return to “qdn.public.ddk.network”