title: Validity of a Socket
body: <p>I have created a socket using the following lines of code and i get a valid socket and connection is established between the client and server machines. Is there a possibility that the socket becomes invalid due to network disturbances or any other reason.</p>
  
  <p>If so how do we check whether the socket is valid or not.</p>
  
  <pre><code>    SOCKET SocServer; 
  
      //To Set up the sockaddr structure 
      ServerSock.sin_family = AF_INET; 
      ServerSock.sin_addr.s_addr = INADDR_ANY     
      ServerSock.sin_port = htons(PortNumber);//port number of 5005 
  
      // To Create a socket for listening on PortNumber 
      if(( SocServer = socket( AF_INET, SOCK_STREAM, 0 )) == INVALID_SOCKET ) 
      { 
          return FALSE; 
      } 
  
      //To bind the socket with wPortNumber 
      if(bind(SocServer,(sockaddr*)&amp;ServerSock,sizeof(ServerSock))!=0) 
      { 
          return FALSE; 
      } 
  
      // To Listen for the connection on wPortNumber 
      if(listen(SocServer,SOMAXCONN)!=0) 
      { 
          return FALSE; 
      }
  </code></pre>
  
  <p>I know i can check for INVALID_SOCKET which in other words means the socket is 0. Is there any other way out because my SocServer will have a value say 2500, i want to check if this socket is valid.</p>