represents a network socket connection.


  • Both SocketConnect and SocketOpen give SocketObject[].
  • Functions that operate on socket connections specified by SocketObject include Read, Write, ReadString, WriteString, BinaryRead and BinaryWrite.
  • Socket connections are closed using Close.
  • SocketConnect creates a socket connection from a source address to a destination address.
  • SocketOpen opens a socket at a destination address that accepts connections from source addresses.
  • Properties of a socket connection can be found using SocketObject[][prop] or Options[SocketObject[],prop]. When applicable, options can be set using SetOptions.
  • Properties for all connections include:
  • "SourceIPAddress"the complete source IP address
    "SourcePort"the source port number (as an integer)
    "DestinationIPAddress"the complete destination IP address
    "DestinationPort"the destination port number (as an integer)
    "Protocol"the connection protocol used ("TCP", "ZMQ", ...)
    "UUID"the asociated UUID for the socket


Basic Examples  (3)

Open a connection to a server specified by a URL:

Write to the socket:

Read the first line of the response:

Close the socket connection:

Connect to a server:

Get the outgoing "SourceIPAddress" on your machine for this socket:

Close the socket:

Open a "ZMQ" socket to listen on and connect a client to it:

The default "Type" for "ZMQ" sockets is "ZMQ_PAIR":

Close the socket:

Wolfram Research (2015), SocketObject, Wolfram Language function, (updated 2017).


Wolfram Research (2015), SocketObject, Wolfram Language function, (updated 2017).


Wolfram Language. 2015. "SocketObject." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017.


Wolfram Language. (2015). SocketObject. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_socketobject, author="Wolfram Research", title="{SocketObject}", year="2017", howpublished="\url{}", note=[Accessed: 21-June-2024 ]}


@online{reference.wolfram_2024_socketobject, organization={Wolfram Research}, title={SocketObject}, year={2017}, url={}, note=[Accessed: 21-June-2024 ]}