# Function Reference

TCPListen

Creates a socket listening for an incoming connection.

TCPListen ( IPAddr, port [, MaxPendingConnection] )

Parameters

IPAddr | Internet Protocol dotted address(IpV4) as "192.162.1.1".
port | port on which the created socket will be connected.
MaxPendingConnection | Maximum length of the queue of pending connections. By default the maximun reasonable value will be set.

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

None.

Related

TCPStartup, TCPConnect, TCPAccept, TCPTimeout (Option)

Example

;SERVER!! Start Me First !!!!!!!!!!!!!!!
$g_IP = "127.0.0.1"
; Start The TCP Services
;==============================================
TCPStartUp()
; Create a Listening "SOCKET"
;==============================================
$MainSocket = TCPListen($g_IP, 65432, 100 )
If $MainSocket = -1 Then Exit