# 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 and set @error according to Windows API WSAGetLasterror return.
| If IPAddr is incorrect @error is set to 1.
| If port is incorrect @error is set to 2.

Remarks

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

Related

TCPStartup, TCPListen, TCPTimeout (Option)

Example

;CLIENT!!!!!!!! Start SERVER First... dummy!!
$g_IP = "127.0.0.1"
; Start The TCP Services
;==============================================
TCPStartUp()
; Connect to a Listening "SOCKET"
;==============================================
$socket = TCPConnect( $g_IP, 65432 )
If $socket = -1 Then Exit