c++ - Validity of a Socket -


I created the socket using the following lines of code and I get a valid socket and establish connection between client and server Is the machines It is likely that the socket network becomes invalid due to disturbances or any other reason.

If so, how do we check whether the socket is valid or not.

  Socket SocServer; // sockaddr structure to set up ServerSock.sin_family = AF_INET; ServerSock.sin_addr.s_addr = INADDR_ANY ServerSock.sin_port = htons (portnumber); To create a socket for the 5005 // port number // portnumber if ((SocServer = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {Description is false; } // wPortNumber to bind the socket (bund (SocServer, (sockaddr *) & ServerSock, sizeof (ServerSock)) = 0) {return false; } // to listen for connections on wPortNumber (Listen (sockers, somexone)! = 0) wrong (return); } I have INVALID_SOCKET which means Socket 0 in other words. There is no other way out because my SocServer can check a value that will check for 2500 , I would like to check if this socket is valid.   

itemprop = "text">

after any one of your socket windows socket works (eg. Pass Hokkopp ( ) ), if the socket is invalid, it will return SOCKET_ERROR , while WSAGetLastError () back WSAENOTSOCK <. / P>

Keep in mind that not equal to INVALID_SOCKET 0 (the actual value, which you should not specifically use ( (Socket) (~ 0))


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -