SocketListener

SocketListener[]

represents a socket listener created by SocketListen.

Details

  • The socket listener can be removed with DeleteObject.
  • Properties of the socket listener can be modified with SocketListener[][prop]=val.
  • The property "Socket" returns the SocketObject being listened on by this SocketListener.
  • The following properties can be modified on the SocketListener:
  • CharacterEncoding$CharacterEncodingthe character encoding to assume
    HandlerFunctionsKeysDefaultkeys to include in the data association
    HandlerFunctionsAutomatichow to handle socket events
    RecordSeparatorsNonehow messages are taken to be delimited
  • The following events can be generated while listening on the socket:
  • "DataReceived"data is available on the socket
  • The following default keys are included in the association for each generated event:
  • "Data"the data received, as a string
    "Socket"the SocketObject being listened on
    "SourceSocket"the SocketObject that generated the event
    "Timestamp"time when the event occurred (as a DateObject)
  • The following additional keys can also be requested in HandlerFunctionsKeys:
  • "DataBytes"the raw data received, as a list of byte values
    "DataByteArray"the raw data received, as a ByteArray object
    "MultipartComplete"whether a multipart ZMQ message is complete

Examples

Basic Examples  (3)

Listen on an available socket to get a SocketListener:

In[1]:=
Click for copyable input
Out[1]=

Get the server socket:

In[2]:=
Click for copyable input

Get the options for the listener:

In[3]:=
Click for copyable input
Out[3]=

Stop listening and close the socket:

In[4]:=
Click for copyable input

Listen on an available socket:

In[1]:=
Click for copyable input
Out[1]=

Get the server socket:

In[2]:=
Click for copyable input

Change the value of the HandlerFunctionsKeys after starting listening on the socket:

In[3]:=
Click for copyable input

Stop listening and close the socket automatically opened for this listener:

In[4]:=
Click for copyable input

Listen on an available socket and get the underlying socket that was opened to connect to it:

In[1]:=
Click for copyable input
Out[1]=

Get the SocketObject that was automatically opened:

In[2]:=
Click for copyable input
Out[2]=

Connect the client:

In[3]:=
Click for copyable input
Out[3]=

Stop listening and close the sockets:

In[4]:=
Click for copyable input

See Also

SocketListen  SocketObject  DeleteObject  ChannelListener

Introduced in 2017
(11.2)