Skip to content

open_socket_connectOpenSocketConnectOpenSocketConnectopen_socket_connectT_open_socket_connectπŸ”—

Short descriptionπŸ”—

open_socket_connectOpenSocketConnectOpenSocketConnectopen_socket_connectT_open_socket_connect β€” Open a socket and connect it to an accepting socket.

SignatureπŸ”—

open_socket_connect( string HostName, number Port, attribute.name GenParamName, attribute.value GenParamValue, out socket Socket )void OpenSocketConnect( const HTuple& HostName, const HTuple& Port, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Socket )static void HOperatorSet.OpenSocketConnect( HTuple hostName, HTuple port, HTuple genParamName, HTuple genParamValue, out HTuple socket )def open_socket_connect( host_name: str, port: int, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[float, int, str]] ) -> HHandle

Herror T_open_socket_connect( const Htuple HostName, const Htuple Port, const Htuple GenParamName, const Htuple GenParamValue, Htuple* Socket )

void HSocket::HSocket( const HString& HostName, Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue )

void HSocket::HSocket( const HString& HostName, Hlong Port, const HString& GenParamName, const HString& GenParamValue )

void HSocket::HSocket( const char* HostName, Hlong Port, const char* GenParamName, const char* GenParamValue )

void HSocket::HSocket( const wchar_t* HostName, Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue ) (Windows only)

public HSocket( string hostName, int port, HTuple genParamName, HTuple genParamValue )

public HSocket( string hostName, int port, string genParamName, string genParamValue )

void HSocket::OpenSocketConnect( const HString& HostName, Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue )

void HSocket::OpenSocketConnect( const HString& HostName, Hlong Port, const HString& GenParamName, const HString& GenParamValue )

void HSocket::OpenSocketConnect( const char* HostName, Hlong Port, const char* GenParamName, const char* GenParamValue )

void HSocket::OpenSocketConnect( const wchar_t* HostName, Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue ) (Windows only)

void HSocket.OpenSocketConnect( string hostName, int port, HTuple genParamName, HTuple genParamValue )

void HSocket.OpenSocketConnect( string hostName, int port, string genParamName, string genParamValue )

DescriptionπŸ”—

open_socket_connectOpenSocketConnect opens a connecting socket to an accepting socket on the computer HostNamehostNamehost_name, which listens on port Portportport.

The following parameters can be set for GenParamNamegenParamNamegen_param_name.

  • 'protocol'"protocol": Specifies the protocol to be used. The 'HALCON'"HALCON" protocol without a specific address family, will use IPv4 or IPv6 automatically depending on the network configuration of the computer. To use a specific address family a β€˜4’ or β€˜6’ (for IPv4 or IPv6, respectively) must be appended to the name of the protocol. For example, 'HALCON4'"HALCON4" designates a HALCON connection over IPv4. Possible values for a generic socket communication are 'UDP'"UDP" and 'TCP'"TCP" which also support appended β€˜4’ and β€˜6’. Alternatively, the usage of addresses for IPv4 (e.g., '127.0.0.1'"127.0.0.1") or IPv6 (e.g., '::1'"::1") for HostNamehostNamehost_name determines the address family to be used. Both communication partners must use the same protocol. To exchange data using generic sockets use send_dataSendData and receive_dataReceiveData only.

    Default: 'HALCON'"HALCON"

  • 'timeout'"timeout": Sets a timeout for this operation. The timeout is given in seconds or as the string 'infinite'"infinite".

  • 'tls_enable'"tls_enable": Controls the use of Transport Layer Security (TLS) for the new socket connection. When 'tls_enable'"tls_enable" is set to 'true'"true", a connection attempt using TLS is undertaken. This requires TLS support on the server side. The certificate to optionally check against is specified with the generic parameter 'tls_certificate'"tls_certificate". Without a certificate, the connection will still be encrypted, but the authenticity of the server can not be verified.

    Default: 'false'"false"

  • 'tls_certificate'"tls_certificate": Specify the path to a certificate to check the authenticity of the server of connection using Transport Layer Security (TLS). The certificate must be provided in PEM-format. This parameter is ignored if 'tls_enable'"tls_enable" is not set to 'true'"true".

  • 'tsl_sni'"tsl_sni": Set the β€œserver name indication” to use for the TLS connection. This tells the server for which domain the certificate should be valid, which is important if multiple domains are hosted on the same server. This parameter is ignored if 'tls_enable'"tls_enable" is not set to 'true'"true".

  • 'string_encoding'"string_encoding": Sets the string encoding that is expected when sending and receiving strings with this socket. It is used for send_tupleSendTuple and receive_tupleReceiveTuple as well as send_dataSendData and receive_dataReceiveData. When the protocol 'HALCON'"HALCON" is used, the setting only has effect on connections to HALCON versions prior to 18.11. If the connection partner is detected to have HALCON version 18.11 or newer, UTF-8 is used to encode tuples.

For the 'HALCON'"HALCON" protocol the listening socket must have been created earlier with the operator open_socket_acceptOpenSocketAccept in another HALCON process. To establish the connection, the HALCON process, in which the accepting socket resides, must call socket_accept_connectSocketAcceptConnect. For a detailed example, see open_socket_acceptOpenSocketAccept.

For generic sockets the socket to connect to can be any socket from the same protocol type.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

ParametersπŸ”—

HostNamehostNamehost_name (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Hostname of the computer to connect to.

Default: 'localhost'"localhost"

Portportport (input_control) number β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Port number.

Suggested values: 3000, 45703000, 4570
Value range: 1024 ≀ Port ≀ 65535
Minimum increment: 1
Recommended increment: 1

GenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) β†’ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Names of the generic parameters that can be adjusted for the socket.

Default: [][]
List of values: 'protocol', 'string_encoding', 'timeout', 'tls_certificate', 'tls_enable', 'tls_sni'"protocol", "string_encoding", "timeout", "tls_certificate", "tls_enable", "tls_sni"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value(-array) β†’ (string / real / integer)HTuple (HString / double / Hlong)HTuple (string / double / int / long)MaybeSequence[Union[float, int, str]]Htuple (char* / double / Hlong)

Values of the generic parameters that can be adjusted for the socket.

Default: [][]
Suggested values: 0, 3.0, 'infinite', 'HALCON', 'UDP', 'TCP', 'HALCON4', 'UDP4', 'TCP4', 'HALCON6', 'UDP6', 'TCP6', 'utf8', 'locale', 'ignore', 'true', 'false'0, 3.0, "infinite", "HALCON", "UDP", "TCP", "HALCON4", "UDP4", "TCP4", "HALCON6", "UDP6", "TCP6", "utf8", "locale", "ignore", "true", "false"

Socketsocketsocket (output_control) socket β†’ (handle)HTuple (HHandle)HSocket, HTuple (IntPtr)HHandleHtuple (handle)

Socket number.

Combinations with other operatorsπŸ”—

Combinations

Possible successors

send_imageSendImage, receive_imageReceiveImage, send_regionSendRegion, receive_regionReceiveRegion, send_tupleSendTuple, receive_tupleReceiveTuple, send_dataSendData, receive_dataReceiveData

See also

open_socket_acceptOpenSocketAccept, socket_accept_connectSocketAcceptConnect, get_socket_paramGetSocketParam, set_socket_paramSetSocketParam, close_socketCloseSocket

ModuleπŸ”—

Foundation