Discussion:
SO_RCVTIMEO
(too old to reply)
Andy Grimm
2004-07-28 00:07:27 UTC
Permalink
I can use setsockopt() to define SO_RCVTIMEO and SO_SNDTIMEO but they
don't seem to prevent my socket from eternally blocking on I/O calls.
Is it true that these options have no effect in VxWorks (actually I'm
using the Tornado VxSim)? If so, what is the best option for timing
out, would it be to use select()?

Thanks!
joe durusau
2004-07-28 11:57:50 UTC
Permalink
Post by Andy Grimm
I can use setsockopt() to define SO_RCVTIMEO and SO_SNDTIMEO but they
don't seem to prevent my socket from eternally blocking on I/O calls.
Is it true that these options have no effect in VxWorks (actually I'm
using the Tornado VxSim)? If so, what is the best option for timing
out, would it be to use select()?
Thanks!
It's not clear why you would want a task to proceed when it has
nothing to do.
In most cases, a task that is doing IO should block until something is
ready. Select
is the mechanism of choice if you have multiple sockets open. You will
only
create a mess if you try of overide blocking on STREAM sockets. With
DGRAM sockets, you could use non-blocking sockets, provided that you did
something about retrying as required.

As to your question about the sim, sorry, I don't know, never used it.

Speaking only for myself,

Joe Durusau
Andy Grimm
2004-07-28 17:50:14 UTC
Permalink
Post by joe durusau
It's not clear why you would want a task to proceed when it has
nothing to do.
In most cases, a task that is doing IO should block until something is
ready. Select
is the mechanism of choice if you have multiple sockets open. You will
only
create a mess if you try of overide blocking on STREAM sockets. With
DGRAM sockets, you could use non-blocking sockets, provided that you did
something about retrying as required.
As to your question about the sim, sorry, I don't know, never used it.
Well, in this case, the (stream) socket reader task needs to
periodically un-block to check a status variable to determine whether it
should exit. There is a separate task which manages a connection
heartbeat. In the event of a heartbeat timeout, a variable is set
indicating that the socket reader and writer tasks should exit.

Problem is, the socket reader task is forever blocked on a socket read.
I had hoped to allow it break out after periods of inactivity using
SO_RCVTIMEO so that it could check the heartbeat status. However, the
SO_RCVTIMEO option doesn't seem to have any effect, at least in
VxSim...the task remains forever blocked in recv().

I understand that I can use select() to only do a recv() when there is
pending data to be read. It looks like that is my only option if the
SO_RCVTIMEO socket option is non-functional in VxWorks.
joe durusau
2004-07-28 20:50:54 UTC
Permalink
Post by Andy Grimm
Post by joe durusau
It's not clear why you would want a task to proceed when it has
nothing to do.
In most cases, a task that is doing IO should block until something is
ready. Select
is the mechanism of choice if you have multiple sockets open. You will
only
create a mess if you try of overide blocking on STREAM sockets. With
DGRAM sockets, you could use non-blocking sockets, provided that you did
something about retrying as required.
As to your question about the sim, sorry, I don't know, never used it.
Well, in this case, the (stream) socket reader task needs to
periodically un-block to check a status variable to determine whether it
should exit. There is a separate task which manages a connection
heartbeat. In the event of a heartbeat timeout, a variable is set
indicating that the socket reader and writer tasks should exit.
Problem is, the socket reader task is forever blocked on a socket read.
I had hoped to allow it break out after periods of inactivity using
SO_RCVTIMEO so that it could check the heartbeat status. However, the
SO_RCVTIMEO option doesn't seem to have any effect, at least in
VxSim...the task remains forever blocked in recv().
I understand that I can use select() to only do a recv() when there is
pending data to be read. It looks like that is my only option if the
SO_RCVTIMEO socket option is non-functional in VxWorks.
You can use select if you wish. It has a time option that will make
it exit after so many time ticks. Remember that you will not necesarily get
all the data you expect. Select will return if there is any data available,
even
one byte, or if there is a timeout.

Speaking only for myself,

Joe Durusau
Binsparky
2004-07-29 08:15:32 UTC
Permalink
Post by Andy Grimm
Post by joe durusau
It's not clear why you would want a task to proceed when it has
nothing to do.
In most cases, a task that is doing IO should block until something is
ready. Select
is the mechanism of choice if you have multiple sockets open. You will
only
create a mess if you try of overide blocking on STREAM sockets. With
DGRAM sockets, you could use non-blocking sockets, provided that you did
something about retrying as required.
As to your question about the sim, sorry, I don't know, never used it.
Well, in this case, the (stream) socket reader task needs to
periodically un-block to check a status variable to determine whether it
should exit. There is a separate task which manages a connection
heartbeat. In the event of a heartbeat timeout, a variable is set
indicating that the socket reader and writer tasks should exit.
Problem is, the socket reader task is forever blocked on a socket read.
I had hoped to allow it break out after periods of inactivity using
SO_RCVTIMEO so that it could check the heartbeat status. However, the
SO_RCVTIMEO option doesn't seem to have any effect, at least in
VxSim...the task remains forever blocked in recv().
I understand that I can use select() to only do a recv() when there is
pending data to be read. It looks like that is my only option if the
SO_RCVTIMEO socket option is non-functional in VxWorks.
I think you could use ioctl() call with FIOCANCEL attribute on the
socket descriptor from the task which manages a connection heartbeat.
Eg : ioctl(fd,FIOCANCEL,0)
This will free up the task which is blocked on read.But i am not sure
whether this will work on vxsim.No experience.

Regards,
Binish

Loading...