ConnectSock
Description
Makes a connection to a remote host.
Good to know: You will need to call this method to make a connection.
Remarks
Use the ConnectSock method to connect to a listening socket. In synchronous mode, this method returns a socket handle to the connection made, or INVALID_SOCKET (-1) if the call fails. If the call failed, use the LastSockErr property to get the error number (these are standard Winsock errors).
If using asynchronous mode (as indicated by the AsyncUseEvent parameter), the developer should use the EventID parameter to send a unique numeric identifier that will be presented in the ConnectionEstablished event, indicating which ConnectSock the event is in response to. If there is an error, the SocketHandle parameter will be equal to -1, and the application should call the LastSockErr property to determine the nature of the error. Note that in async mode the ConnectSock method will always return 0.
Host
Host to connect to
Port
Port to connect on
StreamType
One of the SQ_PROTOCOL constants (SQ_TCPIP or SQ_UDP). Default is SQ_TCPIP.
AdapterNumber
Specifies which adapter to use. Default is -1, meaning let the system decide which adapter is appropriate.
ConnectTimeout
Timeout in seconds
AsyncUseEvent
Specifies whether to connect asynchronously. If this param
EventID
User provided identifier that is used when the ConnectionEstablished event is fired to identify which ConnectSock call it belongs to.
Prototype
LONG ConnectSock(CHAR* Host, long Port, INT StreamType = SQ_TCPIP, long AdapterNumber = -1, long ConnectTimeout = -1, BOOL AsyncUseEvent = FALSE, long EventID = 0)
Last updated