Date: Thu, 1 Feb 2001 11:17:51 -0700 From: "Justin Booth" <jbooth@ccbill.com> To: <freebsd-net@freebsd.org> Subject: Socket Code problem. Message-ID: <009901c08c7b$4f5aca30$5200000a@win2000befwze1>
next in thread | raw e-mail | index | archive | help
Hello Freebsd-net, The following code has a problem with it. After 16000 or so connections the my tcp connections run out of buffer space, which does not allow me to make any new TCP connections and the system locks up. an netstat -an revieles that there are about 100 sockets in TIME_WAIT and an lsof -n shows about 54000 TCP connections in TCP no PCB, CANTSENDMORE, CANTRECVMORE for this program. Can someone point me in the right direction for clearing this up. /* code snippet #define DEAMON_PORT 2313 void main(){ sockaddr_in name; int listen_socket; // Create Socket listen_socket = socket(PF_INET, SOCK_STREAM, TCP ); ioctl(listen_socket, SO_REUSEADDR); if (listen_socket== -1 ){ printf("Socket Failed to Create listening socket\n exiting\n"); exit (-1); } else{ printf("Socket Created %d\n",listen_socket); } // Create socket info name.sin_family = PF_INET; name.sin_addr.s_addr = INADDR_ANY; name.sin_port = htons(DEAMON_PORT); //Bind Socket if ( bind(listen_socket, (struct sockaddr *) &name, sizeof(name)) == -1){ printf("Socket could not be bound\n"); exit(-1); } // Listen on socket if (listen(listen_socket, 5) == -1){ printf("Error Listening\n"); exit(-1); } while(1){ sockaddr incomming; int in_sock; int in_length; int pid; in_length = sizeof(incomming); // Accept incomming socket in_sock = accept(listen_socket, &incomming, &in_length); printf("open:%d\n",in_sock); if (in_sock == -1){ internal_log("Error Accepting\n"); exit(-1); } pid = fork(); // Fork a thread if (pid == 0){ //printf("master Thread alive looping to listen\n"); } else { //Close the Socket printf("close %s\n", in_sock); shutdown(in_sock,2); close(in_sock); exit(0); } } } end code snippet */ Greatly Appreciated, Justin Booth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?009901c08c7b$4f5aca30$5200000a>