open_socket_accept — Open a socket that accepts connection requests.
open_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
It is possible to specify a
Port of 0, triggering
On most operating systems, using a port number of 0 instructs the
operating system to choose a free port randomly.
The generic parameter 'protocol' may be used to specify the protocol
to be used. The default is the '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'
designates a HALCON connection over IPv4.
Possible values for a generic socket communication are 'UDP' and
'TCP' which also support appended '4' and '6'.
Both communication partners must use the same protocol.
To exchange data using generic sockets use
The generic parameter 'address' can be used to instruct 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' would instruct the socket to accept only connections addressed to the address 'localhost', which normally maps to the local loopback network interface '127.0.0.1'.
The generic parameter 'timeout' can be used to set a timeout for
this socket. The timeout is given in seconds or as the string
'infinite'. It is used especially as timeout and waiting mode
in a following
socket_accept_connect call with the parameter
Wait set to 'auto'.
The generic parameter '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
as well as
receive_data. When the protocol
'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.
The generic parameter 'reuseaddr' can be used to control the
setting of the socket option
The default value is 'true'.
When 'reuseaddr' is set to 'false',
SO_REUSEADDR will not be set.
On Windows Systems, conflicting access on a single port will only be
detected, when 'reuseaddr' is set to 'false'.
The generic parameter 'tls_enable' can be used to control the use of Transport Layer Security (TLS) for the new Socket. The default value is 'false'. When 'tls_enable' is set to 'true', the created socket will accept TLS encrypted connections only. Furthermore, both generic parameters 'tls_private_key' and '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.
The accepting socket is returned in
open_socket_accept returns immediately without waiting for a request
from another process, which must be initiated by calling
open_socket_connect. This allows multiple other processes to connect
to the particular HALCON process that calls
accept an incoming 'HALCON' or 'TCP' connection request,
socket_accept_connect must be called to obtain a socket for the final
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.
Default value: 3000
Suggested values: 3000, 4570
Typical range of values:
Minimum increment: 1
Recommended increment: 1
Names of the generic parameters that can be adjusted for the socket.
Default value: 
List of values: 'address', 'protocol', 'string_encoding', 'timeout', 'tls_certificate', 'tls_enable', 'tls_private_key'
→(string / real / integer)
Values of the generic parameters that can be adjusted for the socket.
Default value: 
Suggested values: 0, 3.0, 'infinite', 'HALCON', 'UDP', 'TCP', 'HALCON4', 'UDP4', 'TCP4', 'HALCON6', 'UDP6', 'TCP6', 'utf8', 'locale', 'ignore', 'true', 'false'
* 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)