Function Reference


TCPConnect

Create a socket connected to an existing server.

TCPConnect ( IPAddr, port )

Parameters

IPAddr Internet Protocol dotted address(IpV4) as "192.162.1.1".
port port on which the created socket will be connected.

Return Value

Success: Returns main socket identifier.
Failure: Returns -1 or 0 and set @error.
@error: 1 IPAddr is incorrect.
2 port is incorrect.
windows API WSAGetError return value (see MSDN).

Remarks

This function is used by a client to communicate with the server.

Related

TCPStartup, TCPListen, TCPTimeout (Option), TCPRecv, TCPSend

Example


;CLIENT!!!!!!!! Start SERVER First... dummy!!
Local $g_IP = "127.0.0.1"

; Start The TCP Services
;==============================================
TCPStartup()

; Connect to a Listening "SOCKET"
;==============================================
Local $socket = TCPConnect($g_IP, 65432)
If $socket = -1 Then Exit