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:

Get the server socket:

Get the options for the listener:

Stop listening and close the socket:

Listen on an available socket:

Get the server socket:

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

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

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

Get the SocketObject that was automatically opened:

Connect the client:

Stop listening and close the sockets:

Wolfram Research (2017), SocketListener, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketListener.html.

Text

Wolfram Research (2017), SocketListener, Wolfram Language function, https://reference.wolfram.com/language/ref/SocketListener.html.

CMS

Wolfram Language. 2017. "SocketListener." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SocketListener.html.

APA

Wolfram Language. (2017). SocketListener. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SocketListener.html

BibTeX

@misc{reference.wolfram_2024_socketlistener, author="Wolfram Research", title="{SocketListener}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SocketListener.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_socketlistener, organization={Wolfram Research}, title={SocketListener}, year={2017}, url={https://reference.wolfram.com/language/ref/SocketListener.html}, note=[Accessed: 22-December-2024 ]}