Skip to content

receive_dataReceiveDataReceiveDatareceive_dataT_receive_data🔗

Short description🔗

receive_dataReceiveDataReceiveDatareceive_dataT_receive_data — Receive arbitrary data from external devices or applications using a generic socket connection.

Signature🔗

receive_data( socket Socket, string Format, out string Data, out string From )void ReceiveData( const HTuple& Socket, const HTuple& Format, HTuple* Data, HTuple* From )static void HOperatorSet.ReceiveData( HTuple socket, HTuple format, out HTuple data, out HTuple from )def receive_data( socket: HHandle, format: MaybeSequence[str] ) -> Tuple[Sequence[HTupleElementType], Sequence[Union[int, str]]]

def receive_data_s( socket: HHandle, format: MaybeSequence[str] ) -> Tuple[HTupleElementType, Sequence[Union[int, str]]]Herror T_receive_data( const Htuple Socket, const Htuple Format, Htuple* Data, Htuple* From )

HTuple HSocket::ReceiveData( const HTuple& Format, HTuple* From ) const

HTuple HSocket::ReceiveData( const HString& Format, HTuple* From ) const

HTuple HSocket::ReceiveData( const char* Format, HTuple* From ) const

HTuple HSocket::ReceiveData( const wchar_t* Format, HTuple* From ) const (Windows only)

HTuple HSocket.ReceiveData( HTuple format, out HTuple from )

HTuple HSocket.ReceiveData( string format, out HTuple from )

Description🔗

receive_dataReceiveData receives arbitrary data over a generic socket connection. The received data is converted from a binary network packet to a value (or a tuple of values) using the parameter Formatformatformat as specification and is well-suited to communicate with external devices or applications. This operator does not support the standard 'HALCON'"HALCON" protocol, but is intended for arbitrary data transfer.

The received data is converted to a value or tuple of values using the parameter Formatformatformat. It is possible to specify multiple formats. In this case the Fromfromfrom parameter will contain a 3rd value which tells you which format has been used to convert the data. To decide which format to use the size of the necessary data for each format is calculated initially. When data is received, the first format string with the matching size is used to convert the data to values.

The parameter Fromfromfrom contains the IP address or hostname and port of the communication partner. For UDP connections it can be used in the send_dataSendData operator to send a response.

Please see send_dataSendData for a detailed description of the format.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Socketsocketsocket (input_control) socket → (handle)HTuple (HHandle)HSocket, HTuple (IntPtr)HHandleHtuple (handle)

Socket number.

Formatformatformat (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Specification how to convert the data to tuples.

Default: 'z'"z"

Datadatadata (output_control) string(-array) → (string / real / integer / handle)HTuple (HString / double / Hlong / HHandle)HTuple (string / double / int / long / HHandle)Sequence[HTupleElementType]Htuple (char* / double / Hlong / handle)

Value (or tuple of values) holding the received and converted data.

Fromfromfrom (output_control) string-array → (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)Sequence[Union[int, str]]Htuple (char* / Hlong)

IP address or hostname and network port of the communication partner.

Combinations with other operators🔗

Combinations

Possible predecessors

open_socket_connectOpenSocketConnect, socket_accept_connectSocketAcceptConnect, get_socket_paramGetSocketParam, set_socket_paramSetSocketParam

Possible successors

close_socketCloseSocket

See also

send_dataSendData

Module🔗

Foundation