4D v13.2

TCP_Open

Home

 
4D v13.2
TCP_Open

TCP_Open 


 

TCP_Open ( hostName ; remotePort ; tcp_ID ; sessionSettings ) -> Function result 
Parameter Type   Description
hostName  String in Host name or IP address
remotePort  Integer in The remote port to connect to (0 = any)
tcp_ID  Longint in Reference to this TCP session
sessionSettings  Integer in TCP session settings 0 = Synchron (Default if omitted) 1 = Asynchron 2 = SSL In Use, Synchron 3 = SSL In Use, Asynchron
Function result  Integer in Error Code

The TCP_Open command initiates an outgoing TCP connection to a domain.

TCP_Open initiates a connection to the remote TCP referenced by hostName, on the port referenced by remotePort (if not 0). A long integer value will be returned to tcp_ID, which will be used by all subsequent TCP calls referring to the session. TCP_Open is set to time out in 30 seconds if no data is received by the session identified by the tcp_ID parameter. The default timeout value can be changed for all commands via IT_SetTimeOut.

hostName is the host name or IP address of the machine that you are opening a connection to.

remotePort indicates the TCP port on the machine indicated by hostName that with which you wish to establish a connection.

Note: After a call to TCP_Open (or TCP_Listen), remotePort may contain a negative value if the value passed to this parameter is above 32767. This will not disturb the connection. As a workaround, you can use an intermediate variable:

 $v_ RemotePort:=v_ RemotePort
 $err:=TCP_Open(v_ RemoteHostIPAdr;0;v_ SessionID)

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.

sessionSettings is an optional parameter of the Integer type giving the user the ability to choose the TCP session settings. Note that these settings are applied to each TCP command called during the session. Default value sets to 0 (Synchron, not SSL).

SSL (Secured Socket Layer) is a protocol that allows secured TCP communications (see the 4D documentation for more information and for installation requirements).

Any TCP connection opened using the TCP_Open command must be closed later using the TCP_Close command.

Asynchronous mode returns control to the 4D kernel immediately without waiting for the connection process to be finished (without waiting for the connection with the remote host to be established). Asynchronous mode is useful for people who do not want all the TCP commands to use 4D time.

Synchronous mode returns control to the 4D kernel (to other 4D processes) only when the connection process is finished (successfully or not).

  • 0 = Synchron mode (Default mode, run as previous versions of 4D Internet Commands)
  • 1 = Asynchron mode
  • 2 = SSL In Use, Synchron. All TCP commands using the reference to this TCP session (tcp_ID) will run in Synchronous mode and use SSL protocol.
  • 3 = SSL In Use, Asynchron. All TCP commands using the reference to this TCP session (tcp_ID) will run in Asynchronous mode and use SSL protocol.

Note: An error 10089 may be returned when passing 2 or 3 if an SSL connection cannot be opened (SLI library not found in the 4D Extensions folder).

Example  

You want to connect to a Web site using Https; check that SLI is correctly installed and open a connection using the 443 port number:

 $vError:=TCP_Open(hostName;443;tcp_ID;2)
 ...
 $vError:=TCP_Close(tcp_ID) `Don't forget to close the session

 
PROPERTIES 

Product: 4D
Theme: IC TCP/IP
Number: 88933

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D Internet Commands 6.8.1

 
SEE ALSO 

IT_SetTimeOut