Click or drag to resize

CSocket.connect Method

X#
Establish a connection of the socket instance to a peer.

Namespace:  VO
Assembly:  VOInternetClasses (in VOInternetClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD connect(
	cIP AS STRING,
	nPort AS WORD
) AS LOGIC
Request Example View Source

Parameters

cIP
Type: String
String containing the host name of an Internet server. Alternately, the string can contain the IP number of the site in ASCII dotted-decimal format (for example, 11.22.3.45).
nPort
Type: Word
Port number at cHostNameOrIP.

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
This method establishes a connection to the specified remote address at port nPort.
Examples
The following example checks whether a remote SMTP server is currently available:
X#
 1FUNCTION Start
 2IF CheckRemote("mail2.cai.com", IPPORT_SMTP, 1000)
 3? "CA's mail server is available"
 4ELSE
 5? "Mail server currently not accessible"
 6ENDIF
 7FUNCTION CheckRemote (cServer AS STRING, nPort AS INT, ;
 8nTimeout AS INT); AS LOGIC  PASCAL
 9LOCAL oSocket   AS CSocket
10LOCAL lRet      AS LOGIC
11oSocket := CSocket{SOCK_STREAM}
12oSocket:TimeOut := nTimeout
13lRet := oSocket:connect(cServer, nPort)
14oSocket:Close()
15RETURN lRet
See Also