Wolfram Language Paclet Repository
Community-contributed installable additions to the Wolfram Language
Wolfram Language WebSocket client and server implementation
Contributed by: Antonis Aristeidou
Tools for creating WebSocket clients and local WebSocket servers
To install this paclet in your Wolfram Language environment,
evaluate this code:
PacletInstall["ToneAr/WebSocketLink"]
To load the code after installation, evaluate this code:
Needs["ToneAr`WebSocketLink`"]
Start a WebSocket server:
| In[1]:= | ![]() |
| Out[1]= | ![]() |
Connect to the server:
| In[2]:= |
| Out[2]= | ![]() |
Write message to from the client to the server:
| In[3]:= |
| Out[3]= |
Write a message from the server to the client:
| In[4]:= |
| Out[4]= |
Read the server messages:
| In[5]:= |
| Out[5]= |
Read the client messages:
| In[6]:= |
| Out[6]= |
Close the WebSocket client:
| In[7]:= |
| Out[7]= |
Dispose the server:
| In[8]:= |
| Out[8]= |
Create an empty list to store received messages:
| In[9]:= |
Start a server on an automatically selected local port and keep received messages in a list:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
Connect a client to the server and send a text message:
| In[11]:= | ![]() |
Retrieve messages from list:
| In[12]:= |
| Out[13]= |
Use the server-side client connection object to send a reply back to the client:
| In[14]:= |
Read the message from the server:
| In[15]:= |
| Out[14]= |
Send structured data as JSON text:
| In[16]:= | ![]() |
| Out[16]= |
Send binary data and receive it as a ByteArray:
| In[17]:= | ![]() |
| Out[18]= |
Use the frame helpers without opening a socket:
| In[19]:= | ![]() |
| Out[19]= |
Close the client and server when finished:
| In[20]:= |
| Out[20]= |