SocketConnect

SocketConnect[address]

opens a connection to a server at the specified socket address.

Details

  • Possible socket addresses include:
  • {host,port}hostname or IP address and port number
    {host,"service"}hostname or IP address and service name
    "host:port"hostname or IP address with port
    URL["url"] or "url"complete URL (e.g. http://www.wolfram.com)
  • Hostnames have forms like "www.wolfram.com".
  • IP addresses can be given as "140.177.0.0" or IPAddress[string], where string is an IPv4 or IPv6 IP address.
  • SocketConnect returns a SocketObject.
  • Close can be used to close a connection opened by SocketConnect.

Examples

Basic Examples  (1)

Open a connection to a server specified by a URL:

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

Write to the socket:

In[2]:=
Click for copyable input

Read the result as a string:

In[3]:=
Click for copyable input

Display the result, without extra newlines:

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

Close the socket connection:

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

See Also

SocketObject  HostLookup  IPAddress  URL

Introduced in 2015
(10.3)