|
Before you debug the program, it is recommended that you telnet ip 9898 to see if you can connect,
Observe the following
1. Normally connected, you can send data through the keyboard
2. Normal connection, but immediately interrupted by the remote host
3. Can't connect. The port is indeed unavailable
Just judging the return value is not enough to determine
m_sock.Create();
if( m_sock.Connect(mReader[i].m_strIP,9898))
{
success;
}
else{
int errorcode=GetLastErro();
if (errorcode==WSAEWOULDBLOCK)
{
//When the socket is non-blocking, then the OnConnect message will be corresponding. In this message response function, you can determine whether to connect, and then disconnect to connect the next IP and port, do not directly loop
}
else
{
// Failed; it is recommended to obtain errorcode to judge the specific code
}
} |
|