Herror ::open_socket_accept (
    const HTuple &Port,
    long *AcceptingSocket
)

Open a socket that accepts connection requests.

::open_socket_accept opens a socket that accepts incoming connection requests by other HALCON processes. 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 Port. The accepting socket is returned in AcceptingSocket. ::open_socket_accept returns immediately without waiting for a request from another process, done by calling ::open_socket_connect in the other process. This allows multiple other processes to connect to the particular HALCON process that calls ::open_socket_accept. To accept an incoming connection request, ::socket_accept_connect must be called after another process has called ::open_socket_connect.


Parameters

Port (input_control)
integer -> HTuple.long
Port number.
Default value: 3000
Typical range of values: 1024 <= Port <= 65535
Minimum increment: 1
Recommended increment: 1

AcceptingSocket (output_control)
socket_id -> long *
Socket number.


Example
/* 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)

Possible Successors

::socket_accept_connect


See also

::open_socket_connect, ::close_socket, ::send_image, ::receive_image, ::send_region, ::receive_region, ::send_tuple, ::receive_tuple


Module

System



Copyright © 1996-2002 MVTec Software GmbH