Archived

This topic is now archived and is closed to further replies.

mr BiCEPS

linux: Socket question

Recommended Posts

mr BiCEPS    140
Hi, I would like to know if there''s a way of making a TCP socket timeout after it has been blocking, waiting to read for a while. I googled a little and it seems like I am supposed to setsockopt with SO_RCVTIMEO. Would this work with TCP sockets in linux? If so, how does one tell if the socket timed out, either completely or partially (got a part of the data it was waiting for but not all)? If I understand things correctly, a struct timeval parameter is also to be sent to setsockopt. Is this correct?

Share this post


Link to post
Share on other sites
mr BiCEPS    140
Ok, nevermind the above. It is definitely not the correct way to do it, especially considering SO_RCVTIMEO is apparently read-only.

I guess I just have redesign my classes to use select(). *sigh*

Share this post


Link to post
Share on other sites