Messages in this thread | | | Date | Sat, 11 Dec 1999 22:59:17 -0800 (PST) | From | David Dyck <> | Subject | accept() doesn't block as it should in 2.3.x kernels |
| |
The following demo code should block on the call to accept but it doesn't in 2.3.x, (where x is 24,27,28,30,31, and 32pre2)
2.2.5, 2.2.13, and 2.2.14pre9 block as expected in accept()
I'm getting ENOTCONN "Transport endpoint is not connected"
The man page for accept(2) leads me to believe that it should block
If no pending connections are present on the queue, and the socket is not marked as non- blocking, accept blocks the caller until a connection is present.
I discovered this when attempting to build perl for 2.3.32pre2 (I'm using libc5.4.44 if that matters) and it failed in when testing lib/io_unix
I will appreciate your comments
Thanks again, David Dyck
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h>
#define PATH "/tmp/sock-test" int main() { int s; pid_t pid; struct sockaddr_un sa = { AF_UNIX, PATH }; char *buf[1024];
unlink(PATH); /* just in case */
s = socket(AF_UNIX, SOCK_STREAM, 0); if (s == -1) { perror("socket"); exit(1); }
if (bind(s, (struct sockaddr *)&sa, strlen(sa.sun_path) + sizeof (sa.sun_family)) == -1) { perror("bind"); exit(1); }
if (listen(s, 5) == -1) { perror("listen"); exit(1); }
{ int s2; int sa2_len; struct sockaddr_un sa2;
if ((s2=accept(s, (struct sockaddr *)&sa2, &sa2_len)) == -1) {perror("accept didn't block"); exit(1); } }
return 0; }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |