receive_dataT_receive_dataReceiveDataReceiveDatareceive_data (算子)

名称

receive_dataT_receive_dataReceiveDataReceiveDatareceive_data — 使用通用套接字连接从外部设备或应用程序接收任意数据。

签名

receive_data( : : Socket, Format : Data, From)

Herror T_receive_data(const Htuple Socket, const Htuple Format, Htuple* Data, Htuple* From)

void ReceiveData(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, HString* From) const

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

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

static void HOperatorSet.ReceiveData(HTuple socket, HTuple format, out HTuple data, out HTuple from)

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

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

def receive_data(socket: HHandle, format: MaybeSequence[str]) -> Tuple[HTupleElementType, Union[int, str]]

描述

receive_datareceive_dataReceiveDataReceiveDataReceiveDatareceive_data 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 FormatFormatFormatFormatformatformat as specification and is well-suited to communicate with external devices or applications. This operator does not support the standard 'HALCON'"HALCON""HALCON""HALCON""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 FormatFormatFormatFormatformatformat. It is possible to specify multiple formats. In this case the FromFromFromFromfromfrom 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 FromFromFromFromfromfrom contains the IP address or hostname and port of the communication partner. For UDP connections it can be used in the send_datasend_dataSendDataSendDataSendDatasend_data operator to send a response.

Please see send_datasend_dataSendDataSendDataSendDatasend_data for a detailed description of the format.

执行信息

参数

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

Socket number.

FormatFormatFormatFormatformatformat (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Specification how to convert the data to tuples.

默认值: 'z' "z" "z" "z" "z" "z"

DataDataDataDatadatadata (输出控制)  string HTupleHTupleElementTypeHTupleHtuple (string / real / integer / handle) (string / double / int / long / HHandle) (HString / double / Hlong / HHandle) (char* / double / Hlong / handle)

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

FromFromFromFromfromfrom (输出控制)  string HTupleUnion[int, str]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

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

可能的前趋

open_socket_connectopen_socket_connectOpenSocketConnectOpenSocketConnectOpenSocketConnectopen_socket_connect, 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

另见

send_datasend_dataSendDataSendDataSendDatasend_data

模块

基础