The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-18-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Code:
	 n = read(newsockfd,buffer,1024);/*read from client*/
	 if (n <= 0) 
	 {
	 	 perror("\n ERROR reading from socket \n");/*check for errors*/
	 	 break;
	 }
A way out of the loop when read returns zero or -1 would be good.