From owner-freebsd-net Thu Feb 1 10:15:24 2001 Delivered-To: freebsd-net@freebsd.org Received: from hadar.cwie.net (hadar.cwie.net [64.38.204.100]) by hub.freebsd.org (Postfix) with ESMTP id 3600137B4EC for ; Thu, 1 Feb 2001 10:15:01 -0800 (PST) Received: from win2000befwze1 (L3-phx-t1-hq-i.cwie.net [64.38.194.18]) by hadar.cwie.net (8.9.3/8.9.3) with SMTP id LAA17958 for ; Thu, 1 Feb 2001 11:14:56 -0700 (MST) Message-ID: <009901c08c7b$4f5aca30$5200000a@win2000befwze1> From: "Justin Booth" To: Subject: Socket Code problem. Date: Thu, 1 Feb 2001 11:17:51 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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