clients use
M_socket=socket (AF_INET SOCK_STREAM, 0).
Return INVALID_SOCKET==m_socket? False: true,
Created 10000 socket, ensure that every time is a success, and then use the
Sockaddr_in addSvr;
AddSvr. Sin_family=AF_INET;
AddSvr. Sin_addr. S_addr=inet_addr (pchIp);
AddSvr. Sin_port=htons (iPort);
Int iReturnValue=https://bbs.csdn.net/topics/connect (m_socket, (SOCKADDR *) & addSvr, sizeof (addSvr));
If (SOCKET_ERROR==iReturnValue)
{
return false;
}
return true;
To connect, if the socket connection fails, there will be a mechanism for a moment on the socket to connect, until the client that all 10000 socket connection is successful, but why the server accept statistics the number of total amounted to less than ten thousand,
Preliminary study about myself, if the server as long as the listen call, if not call any accept, the client has a few can connect successfully, this shows that the return value of the connect and accept there is no direct relationship, that is to say the connect returns a success, but it's already accept, doesn't mean the service side
Everybody help to analyze this phenomenon is not normal, normal and abnormal because what respectively,
If normal, why success connect 10000, while the service side accept less than ten thousand, lost the links is what circumstance,
Is there a way to make sure I do is to create 10000 TCP connection, of course, in the application layer on a send/recv, after recv count should be more accurate, what do you have any other way,
In addition, listen (m_listenSocket, 5) if I listen the second argument to fill a bit bigger, such as 100, the above phenomenon would be much better, attached to test several times no problem, and soon, but feel it is a experience value, Svr to run in different circumstances don't always need to adjust,
CodePudding user response:
Baidu search relevant keywords,CodePudding user response:
Connect the success, is the best way to back point data, such as the connection is successful, the server sends to the client a conn number of connections, this is your actual accept connections of success
CodePudding user response:
Each process under a different Windows operating system can support the maximum number of connections is different, even the Linux/Unix has a limit, unless you build system parametersMore than 2 if it is server 2008 version, system TCP/IP protocol stack has a secondary processing functions, also is the system automatically in the IP layer ahead of the connection is successful, even if in fact the corresponding socket process has not been application layer accept
3 if you are not connected to a successful socket without timely reset, so will soon run out of system resources, main memory is not divided
CodePudding user response:
After customer access, can send a serial number data to the server,After the success of the server connection, client also deliver a number to access data, check whether the serial number on both sides is consistent (if more than the client computer, add up to send the serial number of)
CodePudding user response:
Call the connect success can only explain three-way handshake, a successful response you connect an ACK packet, has nothing to do with the accept