Mailinglist Archive: opensuse-programming (33 mails)

< Previous Next >
Re: [suse-programming-e] EAGAIN on a blocking socket?
  • From: Per Jessen <per@xxxxxxxxxxxx>
  • Date: Thu, 02 Mar 2006 19:56:58 +0100
  • Message-id: <du7f5q$kbe$2@xxxxxxxxxxxxxxxx>
Steve Graegert wrote:

> did not have time to take a closer look at your code, but I think that
> fputs(3) itself is not the culprit since it does not necessarily set
> errno when EOF is encountered

Hmmm, interesting - good point. Does anyone know how to go about
examining the error-condition in such a case then? where fputs()
returns EOF. I also notice on re-reading the man-page for fprintf that
it doesn't return EOF in error-situations, but a negative value.

> Instead you're duplicating the FDs before associating it with a stream
> and the call to fcntl(2) call causes the other (new) FD to be put into
> non-blocking (O_NONBLOCK) as well since the data structures in the
> kernel are shared among them.

That's what Anders said too, yet I'm pretty certain (I'll obviously have
to check again) I checked the the flags of the second fd to make sure
it was blocking.

But that leads me to this question - how to I have one socket where I
want reads to be nonblocking and writes to block? Or am I asking for
something impossible?

/Per Jessen, Z├╝rich

< Previous Next >
List Navigation
Follow Ups