c++ - Same socket getting created -


This piece of code is 5005 where I have created a server socket and is set to listen on a special port number. To say socket function is accepted, the socket is created that is copied into the m_Socket variable and once the end I gave a closed server socket named SocServer which was created locally.

Now, to my question, is it possible that SocServer (initially created) and m_Socket (copy on acceptance of copy) adds the same number to 1500.

  struct sockaddr_in ServerSock; // Socket Address Structure to bind port numbers to char * localIP; Socket socketer; // 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); } // Getting the IP address of sockaddr_in insock unit that connects the structure; Int Inslane = Psychophag (Unsecured); // wPortNumber to accept incoming connections on m_Socket = accept (SocServer, (struct sockaddr *) & amp; insock; & amp; insocklen; // Delete Server Sockets (SocServer = INVALID_SOCKET!) {// Close and Shut Down Socserver (SocServer, 2); Closesocket (SocServer); }  

Is it possible that Socserver and m_socket are similar because

According to my code the socket connection is established and for some reason it closes and TCPView It has been established for some time and there is no relation then.

Note: This is only in some machines and is not always reproducible whether any other network may be related to the problem.

Are you sure that your server did not close the connection to your server? Besides, you did not do any work that uses m_Socket, so I can not tell you if there is a problem handling incoming connections. I do not think that m_socket and sausersaver can end only.


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 -