connectToHost
checkConnection
cancel
getErrMsg
NetworkEngine creates TCP/IP connections with a blocking connect operation. This connect halts the program until it successfully connects or gives up trying.
You can use the PollingConnect class to avoid pausing your program. When complete, the resulting connection is passed to a NetworkEngine thread for sending and receiving data as normal. This means that the NetworkEngine must be initialized before you use PollingConnect on it.
bool connectToHost(string ipAddress, int portNumber, NetworkEngine &netEngine);
bool connectToHost(string ipAddress, int portNumber, NetworkEngine *netEngine);
Starts a polling connect for the specified address and port number. Use netEngine to indicate the NetworkEngine that will handle the resulting connection.
Returns false if an error occurred, and stores a description of the error in errMsg.
After a polling connect has been started with connectToHost, use checkConnection to tell when it completes. checkConnection will return either a positive or a negative result:
Positive value: The connect succeeded! The result is the index of the NetworkEngine thread that is handling this connection.
Negative value: errMsg is set with a description of the problem, and the result is one of the following error codes:
DY_BUSYUNREACHABLE - The connect is still in progress, try again later.
DY_NOTOPEN - The connect failed. We couldn't connect, or you didn't start a connect operation with connectToHost.
Once a positive value or DY_NOTOPEN is returned, the polling connect has completed. You can now start a new connect operation with connectToHost.
Cancels the current polling connect. You can now start a new connect operation with connectToHost.
Returns a description of the most recent error for this object.