<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Gordon Messmer wrote:
<blockquote cite="mid:470F3227.8010901@eburg.com" type="cite">Howard
Wilkinson wrote:
  <br>
  <blockquote type="cite">I wanted to add a socketpair connection from
the master process to the servers which implement the actual
functionality. I created the socketpair, set both ends non-blocking and
added it to the select set of fd's. I get an immediate return saying
that the socket is ready to read but when I issue a recv I get&nbsp; -1
(EAGAIN). Nothing I have tried sets the required behaviour of only
returning when there is 'real' data to read.
    <br>
  </blockquote>
  <br>
You're probably better off asking on a Posix programming list than
here.&nbsp; Wherever you ask, though, you should post the code in question,
or code that demonstrates the problem in a state that can be compiled
and verified by others.&nbsp; While you've described what you think you've
done, you haven't given enough information for us to do anything but
guess at the problem.
  <br>
  <br>
</blockquote>
Can you suggest such a list - I can only find lists for POSIX threads!<br>
<br>
Code goes as follows<br>
<br>
<blockquote>
  <pre><tt>int fd[2] = { -1, -1 };
fd_set rfd;
int rv;
char buf[1024];
struct timeval timeout = { 10, 0 };

rv = socketpair(PF_UNIX, SOCK_DGRAM, 0, fd);
if (rv &lt; 0) Err("socketpair");

fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL, 0) | O_NONBLOCK);

FD_ZERO(rfd);
FD_SET(fd[0], rfd);

rv = select(fd[0]+1, &amp;rfd, NULL, NULL, &amp;timeout);

if (FD_ISSET(fd[0], rfd)) {
        printf("Socket is ready to read\n");
        rv = recv(fd[0], buf, sizeof(buf), MSG_DONTWAIT);
        if (rv &lt; 0) Err("recv - %s(%d)", strerror(errno), errno);
        printf("Socket returned %d bytes\n", rv);
} else {
        printf("Socket is not ready to read\n");
}
exit (0);
</tt></pre>
</blockquote>
I contend that this should (if I understand the semantics correctly)
print out "Socket not ready to read" instead I get "recv - Resource
temporarily unavailable(11)"<br>
<br>
Anybody?<br>
<br>
</body>
</html>