reads the next available message on the specified socket, returning it as a byte array.
Details and Options
- The socket is specified as a SocketObject[…].
- For ZMQ sockets, SocketReadMessage returns the next discrete message sent to the socket. It returns all multi-part elements joined together into a single ByteArray.
- For TCP sockets, SocketReadMessage will return a ByteArray of the data currently in the operating system buffer.
Examplesopen allclose all
Basic Examples (2)
Writing a message from one side will send the message to the other side as a ByteArray:
Turn it into a string with ByteArrayToString:
For TCP sockets, the size of the message returned by SocketReadMessage is not deterministic and is controlled by the operating system:
With ZMQ sockets, a single message is sent for every expression passed to WriteString:
Expressions are written on the socket by default as a string in InputForm:
When writing expressions with Write, an additional newline message will appear in between expressions:
Neat Examples (1)
Wolfram Research (2017), SocketReadMessage, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketReadMessage.html.
Wolfram Language. 2017. "SocketReadMessage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SocketReadMessage.html.
Wolfram Language. (2017). SocketReadMessage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SocketReadMessage.html