Dies ist die alte 4D Dokumentations-Website. Die neue und aktualisierte Dokumentation finden Sie unter developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
TCP_Listen
|
TCP_Listen ( ipAddress ; remotePort ; localPort ; timeout ; tcp_ID ) -> Funktionsergebnis | ||||||||
Parameter | Typ | Beschreibung | ||||||
ipAddress | String |
![]() |
Local IP address to listen to or "" to listen to all available addresses | |||||
![]() |
Remote IP address used (if a variable containing a null string is passed) | |||||||
remotePort | Ganzzahl |
![]() |
*** Parameter ignored *** | |||||
localPort | Ganzzahl |
![]() |
Local port number, 0 = find an unused port to use | |||||
![]() |
Used local port number (if 0 passed) | |||||||
timeout | Ganzzahl |
![]() |
# of seconds to wait, 0 = wait forever | |||||
tcp_ID | Lange Ganzzahl |
![]() |
Reference to this TCP session | |||||
Funktionsergebnis | Ganzzahl |
![]() |
Error Code | |||||
The TCP_Listen command opens a communication "socket" on the port specified by the ipAddress and localPort parameters. This command does not return control back to the 4D calling method until either a connection is made or the timeout period has elapsed. Though it may seem as though this would lock up your database until a connection was made, the command is friendly to other 4D processes that may be running. This command will slice time to other 4D processes you may already have running.
Most developers will want to issue this call from a method which has been spawned into its own 4D process (especially if you specify the timeout period to wait forever).
The ipAddress parameter contains the IP address used for the connection:
localPort contains the TCP port you wish to use for communication. If you pass a zero as this parameter, the command will find any unused port and pass that number back to this parameter.
timeout specifies the number of seconds this command will wait for an incoming connection. A zero in this parameter will cause the command to wait indefinitely for an incoming connection. Caution should be taken when passing a zero since control will never be returned to the calling 4D process if a connection is never made. Never pass zero to this parameter in a single-process database.
tcp_ID is the long integer reference to the session that was opened. This reference will be used in all subsequent TCP external calls that reference this session.
Any TCP connection opened using the TCP_Listen command must be closed later using the TCP_Close command.
C_LONGINT(vTCPID)
C_LONGINT(vStatus)
$err:=TCP_Listen("";0;0;30;vTCPID)
$err:=TCP_State(vTCPID;vStatus)
If(vStatus=2) //socket is open and listening
DoSomething
$err:=TCP_Close(vTCPID)
End if
Produkt: 4D
Thema: IC TCP/IP
Nummer:
88932
Geändert: 4D Internet Commands 6.8.1
4D Internet Commands ( 4D v20 R7)