open_socket_connectT_open_socket_connectOpenSocketConnectOpenSocketConnectopen_socket_connect (算子)

名称

open_socket_connectT_open_socket_connectOpenSocketConnectOpenSocketConnectopen_socket_connect — 打开一个套接字并将其连接到接受套接字。

签名

open_socket_connect( : : HostName, Port, GenParamName, GenParamValue : Socket)

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

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)

def open_socket_connect(host_name: str, port: int, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[float, int, str]]) -> HHandle

描述

open_socket_connectopen_socket_connectOpenSocketConnectOpenSocketConnectOpenSocketConnectopen_socket_connect opens a connecting socket to an accepting socket on the computer HostNameHostNameHostNameHostNamehostNamehost_name, which listens on port PortPortPortPortportport

The following parameters can be set for 'GenParamName'"GenParamName""GenParamName""GenParamName""GenParamName""GenParamName".

'protocol'"protocol""protocol""protocol""protocol""protocol"

Specifies the protocol to be used. The 'HALCON'"HALCON""HALCON""HALCON""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""HALCON4""HALCON4""HALCON4""HALCON4" designates a HALCON connection over IPv4. Possible values for a generic socket communication are 'UDP'"UDP""UDP""UDP""UDP""UDP" and 'TCP'"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""127.0.0.1") or IPv6 (e.g., '::1'"::1""::1""::1""::1""::1") for HostNameHostNameHostNameHostNamehostNamehost_name determines the address family to be used. Both communication partners must use the same protocol. To exchange data using generic sockets use send_datasend_dataSendDataSendDataSendDatasend_data and receive_datareceive_dataReceiveDataReceiveDataReceiveDatareceive_data only.

默认值: 'HALCON'"HALCON""HALCON""HALCON""HALCON""HALCON"

'timeout'"timeout""timeout""timeout""timeout""timeout"

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

'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable""tls_enable"

Controls the use of Transport Layer Security (TLS) for the new socket connection. When 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable""tls_enable" is set to 'true'"true""true""true""true""true", a connection attempt using TLS is undertaken. This requires TLS support on the server side. The generic parameter 'tls_certificate'"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 authenticity of the server can not be verified. The certificate must be provided in PEM-format.

默认值: 'false'"false""false""false""false""false"

'string_encoding'"string_encoding""string_encoding""string_encoding""string_encoding""string_encoding"

Sets the string encoding that is expected when sending and receiving strings with this socket. It is used for send_tuplesend_tupleSendTupleSendTupleSendTuplesend_tuple and receive_tuplereceive_tupleReceiveTupleReceiveTupleReceiveTuplereceive_tuple as well as send_datasend_dataSendDataSendDataSendDatasend_data and receive_datareceive_dataReceiveDataReceiveDataReceiveDatareceive_data。When the protocol 'HALCON'"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.

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

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

执行信息

此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。

参数

HostNameHostNameHostNameHostNamehostNamehost_name (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Hostname of the computer to connect to.

默认值: 'localhost' "localhost" "localhost" "localhost" "localhost" "localhost"

PortPortPortPortportport (输入控制)  number HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Port number.

建议值: 3000, 4570

值范围: 1024 ≤ Port Port Port Port port port ≤ 65535

最小增量: 1

建议增量: 1

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

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

默认值: []

值列表: 'protocol'"protocol""protocol""protocol""protocol""protocol", 'string_encoding'"string_encoding""string_encoding""string_encoding""string_encoding""string_encoding", 'timeout'"timeout""timeout""timeout""timeout""timeout", 'tls_certificate'"tls_certificate""tls_certificate""tls_certificate""tls_certificate""tls_certificate", 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable""tls_enable"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制)  attribute.value(-array) HTupleMaybeSequence[Union[float, int, str]]HTupleHtuple (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.

默认值: []

建议值: 0, 3.0, 'infinite'"infinite""infinite""infinite""infinite""infinite", 'HALCON'"HALCON""HALCON""HALCON""HALCON""HALCON", 'UDP'"UDP""UDP""UDP""UDP""UDP", 'TCP'"TCP""TCP""TCP""TCP""TCP", 'HALCON4'"HALCON4""HALCON4""HALCON4""HALCON4""HALCON4", 'UDP4'"UDP4""UDP4""UDP4""UDP4""UDP4", 'TCP4'"TCP4""TCP4""TCP4""TCP4""TCP4", 'HALCON6'"HALCON6""HALCON6""HALCON6""HALCON6""HALCON6", 'UDP6'"UDP6""UDP6""UDP6""UDP6""UDP6", 'TCP6'"TCP6""TCP6""TCP6""TCP6""TCP6", 'utf8'"utf8""utf8""utf8""utf8""utf8", 'locale'"locale""locale""locale""locale""locale", 'ignore'"ignore""ignore""ignore""ignore""ignore", 'true'"true""true""true""true""true", 'false'"false""false""false""false""false"

SocketSocketSocketSocketsocketsocket (输出控制)  socket HSocket, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Socket number.

可能的后继

send_imagesend_imageSendImageSendImageSendImagesend_image, receive_imagereceive_imageReceiveImageReceiveImageReceiveImagereceive_image, send_regionsend_regionSendRegionSendRegionSendRegionsend_region, receive_regionreceive_regionReceiveRegionReceiveRegionReceiveRegionreceive_region, send_tuplesend_tupleSendTupleSendTupleSendTuplesend_tuple, receive_tuplereceive_tupleReceiveTupleReceiveTupleReceiveTuplereceive_tuple, send_datasend_dataSendDataSendDataSendDatasend_data, receive_datareceive_dataReceiveDataReceiveDataReceiveDatareceive_data

另见

open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept, socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnectsocket_accept_connect, get_socket_paramget_socket_paramGetSocketParamGetSocketParamGetSocketParamget_socket_param, set_socket_paramset_socket_paramSetSocketParamSetSocketParamSetSocketParamset_socket_param, close_socketclose_socketCloseSocketCloseSocketCloseSocketclose_socket

模块

基础