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 [optional] Maximum length of the queue of pending connections. By default the maximum reasonable value will be set.

 

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

None.

 

Related

TCPStartup, TCPConnect, TCPAccept, TCPTimeout (Option), TCPCloseSocket, TCPSend, TCPShutdown

 

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