open_socket_acceptT_open_socket_acceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept (算子)
名称
open_socket_acceptT_open_socket_acceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept — 打开一个接受连接请求的套接字。
签名
void OpenSocketAccept(const HTuple& Port, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* AcceptingSocket)
void HSocket::HSocket(Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue)
void HSocket::HSocket(Hlong Port, const HString& GenParamName, const HString& GenParamValue)
void HSocket::HSocket(Hlong Port, const char* GenParamName, const char* GenParamValue)
void HSocket::HSocket(Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
void HSocket::OpenSocketAccept(Hlong Port, const HTuple& GenParamName, const HTuple& GenParamValue)
void HSocket::OpenSocketAccept(Hlong Port, const HString& GenParamName, const HString& GenParamValue)
void HSocket::OpenSocketAccept(Hlong Port, const char* GenParamName, const char* GenParamValue)
void HSocket::OpenSocketAccept(Hlong Port, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
static void HOperatorSet.OpenSocketAccept(HTuple port, HTuple genParamName, HTuple genParamValue, out HTuple acceptingSocket)
public HSocket(int port, HTuple genParamName, HTuple genParamValue)
public HSocket(int port, string genParamName, string genParamValue)
void HSocket.OpenSocketAccept(int port, HTuple genParamName, HTuple genParamValue)
void HSocket.OpenSocketAccept(int port, string genParamName, string genParamValue)
描述
open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept opens a socket that will accept incoming
connection requests. This operator is the
necessary first step in the establishment of a communication channel
between two HALCON processes. The socket listens for incoming
connection requests on the port number given by PortPortPortPortportport。
It is possible to specify a PortPortPortPortportport of 0, triggering
implementation-defined behavior.
On most operating systems, using a port number of 0 instructs the
operating system to choose a free port randomly.
The following parameters can be set for GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name。
- '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'.
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"
- 'adress'"adress""adress""adress""adress""adress":
-
Instructs the socket to accept only connection requests addressed to a
specific address. This address is specified as either an IPv4 or IPv6
address in numerical form, or a hostname. For example, 'localhost'"localhost""localhost""localhost""localhost""localhost"
would instruct the socket to accept only connections addressed to the
address 'localhost'"localhost""localhost""localhost""localhost""localhost", which normally maps to the local loopback
network interface '127.0.0.1'"127.0.0.1""127.0.0.1""127.0.0.1""127.0.0.1""127.0.0.1".
- 'timeout'"timeout""timeout""timeout""timeout""timeout":
-
Sets a timeout for this socket. The timeout is given in seconds or as
the string 'infinite'"infinite""infinite""infinite""infinite""infinite". It is used especially as timeout and
waiting mode in a following socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnectsocket_accept_connect call with
the parameter WaitWaitWaitWaitwaitwait set to 'auto'"auto""auto""auto""auto""auto".
- '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.
- 'reuseaddr'"reuseaddr""reuseaddr""reuseaddr""reuseaddr""reuseaddr":
-
Controls the setting of the socket option SO_REUSEADDR.
When 'reuseaddr'"reuseaddr""reuseaddr""reuseaddr""reuseaddr""reuseaddr" is set to 'false'"false""false""false""false""false",
SO_REUSEADDR will not be set.
On Windows Systems, conflicting access on a single port will only be
detected, when 'reuseaddr'"reuseaddr""reuseaddr""reuseaddr""reuseaddr""reuseaddr" is set to 'false'"false""false""false""false""false".
默认值:
'true'"true""true""true""true""true"
- 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable""tls_enable":
-
Controls the use of Transport Layer Security (TLS) for the new Socket.
When 'tls_enable'"tls_enable""tls_enable""tls_enable""tls_enable""tls_enable" is set to 'true'"true""true""true""true""true", the created socket
will accept TLS secured connections only. Furthermore, both generic
parameters 'tls_private_key'"tls_private_key""tls_private_key""tls_private_key""tls_private_key""tls_private_key" and 'tls_certificate'"tls_certificate""tls_certificate""tls_certificate""tls_certificate""tls_certificate" must be
set, each with a path to the private certificate key and the path to the
public server certificate. Private key and server certificate must be
provided in PEM-format.
默认值:
'false'"false""false""false""false""false"
The accepting socket is returned in AcceptingSocketAcceptingSocketAcceptingSocketAcceptingSocketacceptingSocketaccepting_socket.
open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept returns immediately without waiting for a request
from another process, which must be initiated by calling
open_socket_connectopen_socket_connectOpenSocketConnectOpenSocketConnectOpenSocketConnectopen_socket_connect。This allows multiple other processes to connect
to the particular HALCON process that calls open_socket_acceptopen_socket_acceptOpenSocketAcceptOpenSocketAcceptOpenSocketAcceptopen_socket_accept. To
accept an incoming 'HALCON'"HALCON""HALCON""HALCON""HALCON""HALCON" or 'TCP'"TCP""TCP""TCP""TCP""TCP" connection request,
socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnectsocket_accept_connect must be called to obtain a socket for the final
communication.
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。
参数
PortPortPortPortportport (输入控制) number → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Port number.
默认值:
3000
建议值:
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.
默认值:
[]
值列表:
'address'"address""address""address""address""address", '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", 'tls_private_key'"tls_private_key""tls_private_key""tls_private_key""tls_private_key""tls_private_key"
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"
AcceptingSocketAcceptingSocketAcceptingSocketAcceptingSocketacceptingSocketaccepting_socket (输出控制) socket → HSocket, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Socket number.
示例(HDevelop)
* Process 1
dev_set_colored (12)
open_socket_accept (3000, [], [], AcceptingSocket)
* Busy wait for an incoming connection
dev_error_var (Error, 1)
dev_set_check ('~give_error')
OpenStatus := 5
while (OpenStatus != 2)
socket_accept_connect (AcceptingSocket, 'false', Socket)
OpenStatus := Error
wait_seconds (0.2)
endwhile
dev_set_check ('give_error')
* Connection established
receive_image (Image, Socket)
threshold (Image, Region, 0, 63)
send_region (Region, Socket)
receive_region (ConnectedRegions, Socket)
area_center (ConnectedRegions, Area, Row, Column)
send_tuple (Socket, Area)
send_tuple (Socket, Row)
send_tuple (Socket, Column)
close_socket (Socket)
close_socket (AcceptingSocket)
* Process 2
dev_set_colored (12)
open_socket_connect ('localhost', 3000, [], [], Socket)
read_image (Image, 'fabrik')
send_image (Image, Socket)
receive_region (Region, Socket)
connection (Region, ConnectedRegions)
send_region (ConnectedRegions, Socket)
receive_tuple (Socket, Area)
receive_tuple (Socket, Row)
receive_tuple (Socket, Column)
close_socket (Socket)
可能的后继
socket_accept_connectsocket_accept_connectSocketAcceptConnectSocketAcceptConnectSocketAcceptConnectsocket_accept_connect
另见
open_socket_connectopen_socket_connectOpenSocketConnectOpenSocketConnectOpenSocketConnectopen_socket_connect,
close_socketclose_socketCloseSocketCloseSocketCloseSocketclose_socket,
get_socket_paramget_socket_paramGetSocketParamGetSocketParamGetSocketParamget_socket_param,
set_socket_paramset_socket_paramSetSocketParamSetSocketParamSetSocketParamset_socket_param,
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
模块
基础