SocketWriteMessage[socket,ba]
writes byte array ba to the specified socket.
SocketWriteMessage[socket,string]
writes string to the specified socket.
SocketWriteMessage[socket,assoc]
writes messages specified by assoc to the specified socket.
SocketWriteMessage
SocketWriteMessage[socket,ba]
writes byte array ba to the specified socket.
SocketWriteMessage[socket,string]
writes string to the specified socket.
SocketWriteMessage[socket,assoc]
writes messages specified by assoc to the specified socket.
Details and Options
- SocketWriteMessage is supported for web sockets only. This means that the SocketObject should have a protocol of "WS" or "WSS".
- SocketWriteMessage sends messages to an active web socket server.
- Message data in the web socket protocol can be be either binary or text, but not both at the same time.
- Message data is sent as text by default, but can be sent as binary by using an assoc.
- Supported keys for assoc include:
-
"DataByteArray" data specified as a byte array "Type" type of the data,either "Text" or "Binary" "MultipartComplete" whether the message is complete - If the value for "MultipartComplete" is False, the message must be completed in a future call to SocketWriteMessage.
Examples
Basic Examples (1)
Connect to a reference web socket server that echoes the messages it receives:
socket = SocketConnect["wss://echo.websocket.org"]Read the initial response from the server:
SocketReadMessage[socket]SocketWriteMessage[socket, StringToByteArray["hello"]]out = SocketReadMessage[socket]Convert the byte array to a human-readable string:
ByteArrayToString[out["DataByteArray"]]Related Guides
History
Text
Wolfram Research (2026), SocketWriteMessage, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketWriteMessage.html.
CMS
Wolfram Language. 2026. "SocketWriteMessage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SocketWriteMessage.html.
APA
Wolfram Language. (2026). SocketWriteMessage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SocketWriteMessage.html
BibTeX
@misc{reference.wolfram_2026_socketwritemessage, author="Wolfram Research", title="{SocketWriteMessage}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/SocketWriteMessage.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_socketwritemessage, organization={Wolfram Research}, title={SocketWriteMessage}, year={2026}, url={https://reference.wolfram.com/language/ref/SocketWriteMessage.html}, note=[Accessed: 12-June-2026]}