// ---------------------------------------------------
// connect a client and return the socket handle
// ---------------------------------------------------
dword clientConnect(dword targetIP, dword port)
{
dword resultSocket;
resultSocket = TcpOpen (0,0);
if (resultSocket != ~0)
{
TcpConnect ( resultSocket, targetIP, port );
// => Connection established in callback OnTcpConnect...
}
else
{
writeLineEx(1, 3, " [ TcpOpen: FAILED. ]");
}
return resultSocket;
}
// ---------------------------------------------------
// Connection operation completes
// ---------------------------------------------------
void OnTcpConnect( dword socket, long result)
{
if (result == 0)
{
// start receiving on socket using TcpReceive …
}
else
{
writeLineEx(1, 3, "OnTcpConnect error %d", result);
}
}