sockConnect (Function) |
Top Previous Next |
Initiates a TCP/IP socket connection to the specified IP address/port number. When this function returns, the connection has not been finally established but only initiated. The establishing of the connection must be determined by using the sockConnection() function block. It is possible to establish a maximum of 8 simultaneous socket connections.
Please note that for each sockConnect() there must be a sockDisconnect(), even if the connection is closed from the "outside" (see example below).
Input: ip : DINT 32 bit IP address to connect to.
port : DINT Port number to connect to an IP address.
iface : SINT (default 0) The network interface to use. 0 = Default network, 1 = Mobile network, 2 = LAN network, etc. (See Network) Note: For backwards compatibility the Mobile network is used as default network.
Returns: SINT ID of the connection. If return value is 0, the connection could not be initiated (possibly because there are too many sockConnect() without corresponding sockDisconnect()).
Declaration: FUNCTION sockConnect : SINT;
Example:
|