Create a client socket that opens up a connection with a server to send and receive requests.
Using Raw TCP Sockets...
Connect to a host address
Use HostLookup to get the IPAddress of example.com:
address = HostLookup["example.com"]Use SocketConnect to connect to the host address:
client = SocketConnect[Append[address, 80]]Submit a request to the server
Use WriteString to submit an HTTP request to the server:
WriteString[client, "GET / HTTP/1.1\r
Host: example.com\r
\r
"]Read the response
Use SocketReadMessage to read in the whole HTTP response:
SocketReadMessage[client]//ByteArrayToStringClose the connection
Use Close to disconnect from the server:
Close[client]Using ZMQ Sockets...
Connect to a host address
Use HostLookup to get the IPAddress of example.com:
address = HostLookup["example.com"]Use SocketConnect to connect to the host address:
client = SocketConnect[Append[address, 80], "ZMQ_PAIR"]Submit a request to the server
Use WriteString to submit an HTTP request to the server:
WriteString[client, "GET / HTTP/1.1\r
Host: example.com\r
\r
"]Read the response
SocketReadMessage[client]//ByteArrayToStringClose the connection
Use Close to disconnect from the server:
Close[client]Related Functions
HostLookup IPAddress SocketConnect WriteString ReadString Sockets Close