open_socket_connectT_open_socket_connectOpenSocketConnectOpenSocketConnect (Operator)
Name
open_socket_connectT_open_socket_connectOpenSocketConnectOpenSocketConnect
— Open a socket and connect it to an accepting socket.
Signature
void OpenSocketConnect(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)
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)
static void HOperatorSet.OpenSocketConnect(HTuple hostName, HTuple port, HTuple genParamName, HTuple genParamValue, out HTuple socket)
public HSocket(string hostName, int port, HTuple genParamName, HTuple genParamValue)
public HSocket(string hostName, int port, string genParamName, string genParamValue)
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_connectopen_socket_connectOpenSocketConnectOpenSocketConnectOpenSocketConnect
opens a connecting socket to an accepting
socket on the computer HostNameHostNameHostNameHostNamehostName
, which listens on port
PortPortPortPortport
.
The parameter 'protocol'"protocol""protocol""protocol""protocol" may be used to specify the protocol to be
used. The default is the 'HALCON'"HALCON""HALCON""HALCON""HALCON" protocol without specific address
family. Therefore, IPv4 or IPv6 will be used 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""HALCON4""HALCON4""HALCON4"
designates a HALCON connection over IPv4.
Possible values for a generic socket communication are 'UDP'"UDP""UDP""UDP""UDP" and
'TCP'"TCP""TCP""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""127.0.0.1""127.0.0.1""127.0.0.1") or
IPv6 (e.g. '::1'"::1""::1""::1""::1") for HostNameHostNameHostNameHostNamehostName
determines the address
family to be used.
Both communication partners must use the same protocol.
To exchange data using generic sockets use send_datasend_dataSendDataSendDataSendData
and
receive_datareceive_dataReceiveDataReceiveDataReceiveData
only.
The generic parameter 'timeout'"timeout""timeout""timeout""timeout" can be used to set a timeout
for this operation. The timeout is given in seconds or as the string
'infinite'"infinite""infinite""infinite""infinite".
The generic parameter 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable" can be used to control the
use of Transport Layer Security (TLS) for the new Socket.
The default value is 'false'"false""false""false""false".
When 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable" is set to 'true'"true""true""true""true", Transport Layer
Security (TLS) will be used to secure the network connection. The accepting
Socket must be opened first using open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAccept
with
'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable" set to 'true'"true""true""true""true".
The generic parameter 'tls_certificate'"tls_certificate""tls_certificate""tls_certificate""tls_certificate" may be used to provide
a path to a certificate to check the authenticity of the server. Without
the certificate, the connection will still be encrypted, but the authenticy
of the server can not be verified. The certificate must be provided in
PEM-format.
For the 'HALCON'"HALCON""HALCON""HALCON""HALCON" protocol the listening socket must have been
created earlier with the operator open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAccept
in another
HALCON process. To establish the connection, the HALCON process, in which the
accepting socket resides, must call socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnect
. For a
detailed example, see open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAccept
.
For generic sockets the socket to connect to can be any socket from the
same protocol type.
The generic parameter 'string_encoding'"string_encoding""string_encoding""string_encoding""string_encoding" can be used to set the
string encoding that is expected when sending and receiving strings with
this socket. It is used for send_tuplesend_tupleSendTupleSendTupleSendTuple
and receive_tuplereceive_tupleReceiveTupleReceiveTupleReceiveTuple
as well as send_datasend_dataSendDataSendDataSendData
and receive_datareceive_dataReceiveDataReceiveDataReceiveData
. When the protocol
'HALCON'"HALCON""HALCON""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.
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
HostNameHostNameHostNameHostNamehostName
(input_control) string →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Hostname of the computer to connect to.
Default value:
'localhost'
"localhost"
"localhost"
"localhost"
"localhost"
PortPortPortPortport
(input_control) number →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Port number.
Suggested values: 3000, 4570
Typical range of values: 1024
≤
Port
Port
Port
Port
port
≤
65535
Minimum increment: 1
Recommended increment: 1
GenParamNameGenParamNameGenParamNameGenParamNamegenParamName
(input_control) attribute.name(-array) →
HTupleHTupleHtuple (string) (string) (HString) (char*)
Names of the generic parameters that can be
adjusted for the socket.
Default value: []
List of values: 'protocol'"protocol""protocol""protocol""protocol", 'string_encoding'"string_encoding""string_encoding""string_encoding""string_encoding", 'timeout'"timeout""timeout""timeout""timeout", 'tls_certificate'"tls_certificate""tls_certificate""tls_certificate""tls_certificate", 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable"
GenParamValueGenParamValueGenParamValueGenParamValuegenParamValue
(input_control) attribute.value(-array) →
HTupleHTupleHtuple (string / real / integer) (string / double / int / long) (HString / double / Hlong) (char* / double / Hlong)
Values of the generic parameters that can be
adjusted for the socket.
Default value: []
Suggested values: 0, 3.0, 'infinite'"infinite""infinite""infinite""infinite", 'HALCON'"HALCON""HALCON""HALCON""HALCON", 'UDP'"UDP""UDP""UDP""UDP", 'TCP'"TCP""TCP""TCP""TCP", 'HALCON4'"HALCON4""HALCON4""HALCON4""HALCON4", 'UDP4'"UDP4""UDP4""UDP4""UDP4", 'TCP4'"TCP4""TCP4""TCP4""TCP4", 'HALCON6'"HALCON6""HALCON6""HALCON6""HALCON6", 'UDP6'"UDP6""UDP6""UDP6""UDP6", 'TCP6'"TCP6""TCP6""TCP6""TCP6", 'utf8'"utf8""utf8""utf8""utf8", 'locale'"locale""locale""locale""locale", 'ignore'"ignore""ignore""ignore""ignore", 'true'"true""true""true""true", 'false'"false""false""false""false"
SocketSocketSocketSocketsocket
(output_control) socket →
HSocket, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Socket number.
Possible Successors
send_imagesend_imageSendImageSendImageSendImage
,
receive_imagereceive_imageReceiveImageReceiveImageReceiveImage
,
send_regionsend_regionSendRegionSendRegionSendRegion
,
receive_regionreceive_regionReceiveRegionReceiveRegionReceiveRegion
,
send_tuplesend_tupleSendTupleSendTupleSendTuple
,
receive_tuplereceive_tupleReceiveTupleReceiveTupleReceiveTuple
,
send_datasend_dataSendDataSendDataSendData
,
receive_datareceive_dataReceiveDataReceiveDataReceiveData
See also
open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAccept
,
socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnect
,
get_socket_paramget_socket_paramGetSocketParamGetSocketParamGetSocketParam
,
set_socket_paramset_socket_paramSetSocketParamSetSocketParamSetSocketParam
,
close_socketclose_socketCloseSocketCloseSocketCloseSocket
Module
Foundation