Date: Sat, 14 Mar 1998 01:08:39 -0600 (CST) From: Tony Kimball <alk@pobox.com> To: questions@FreeBSD.ORG Subject: accept fails me -- why? Message-ID: <199803140708.BAA22691@pobox.com>
next in thread | raw e-mail | index | archive | help
I thought I understood this stuff cold... but now I wonder... In this trivial program, the accept call fails with EINVAL. Go figure. Any suggestions? #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> int main(int ac, char **av) { int server_port; int server_fd; int client_fd; struct sockaddr_in sname; int arg = sizeof(sname); int one = 1; server_port = 2001; server_fd = socket(AF_INET, SOCK_STREAM, 0); if (server_fd == -1) perror("server socket failed"); setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)); sname.sin_family = AF_INET; sname.sin_port = htons((u_short)server_port); sname.sin_addr.s_addr = INADDR_ANY; if (bind(server_fd,(struct sockaddr *)&sname,sizeof(sname))) perror("server bind failed"); client_fd = accept(server_fd,(struct sockaddr *)&sname,&arg); if (client_fd == -1) perror("client accept failed"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803140708.BAA22691>