Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

read system call hangs

81 views
Skip to first unread message

Jaydeep Chovatia

unread,
May 21, 2012, 6:10:47 PM5/21/12
to
Hi,

I am using "read" system call in my C++ project (Redhat Linux) to read data from sockets. I have also set read timeout (SO_RCVTIMEO) to 5 seconds using "setsockopt", but when I run my application under load run then sometimes this "read" system call hangs, it neither returns data nor it times out.

Any suggestion/help would be appreciated.

Thank you,
Jaydeep

Volker Birk

unread,
May 22, 2012, 12:02:05 AM5/22/12
to
Just a guess: why not using recv(2) instead of read(2) ?

Yours,
VB.
--
"Warum machen wir den Massenmörder Breivik zum Popstar des Bösen?"
"Weil eine Million Sarrazin-Buchkäufer schlechter aufs Gruppenfoto passen."
Friedrich Küppersbusch in <https://www.taz.de/Die-Woche/!91993/>

Barry Margolin

unread,
May 22, 2012, 9:06:06 AM5/22/12
to
In article <jpf33t...@news.in-ulm.de>,
Volker Birk <bum...@dingens.org> wrote:

> Jaydeep Chovatia <chovatia...@gmail.com> wrote:
> > I am using "read" system call in my C++ project (Redhat Linux) to read
> > data from sockets. I have also set read timeout (SO_RCVTIMEO) to 5
> > seconds using "setsockopt", but when I run my application under load
> > run then sometimes this "read" system call hangs, it neither returns
> > data nor it times out.
> > Any suggestion/help would be appreciated.
>
> Just a guess: why not using recv(2) instead of read(2) ?

According to the man page for the SO_RCVTIMEO and SO_SNDTIMEO options,
both calls should be affected. read() is just recv() with default
options.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
0 new messages