sock supports two modes: listening mode and originating mode. In the listening mode (requested by the -l option), sock acts as an server and accepts incoming connections for the network address specified as <local> (see below for how to write addresses). In the originating mode, you specify an address (<remote>) to connect to and maybe also the local address (-b <local>) to bind the local end to.
By default, sock just copies its standard input to the socket and all data received from the socket to its standard output. If you want, you can specify a <command> to be spawned and the socket redirected to its standard input/output instead (in the listening mode, you can use -d to wait for multiple connections and spawn the command for each of them instead of exiting after serving a single incoming connection).
For UNIX domain sockets, just use a socket file name as an address.
For IP (TCP/UDP) sockets, addresses look like [<host>][:<port>], where <host> is a host name and <port> is a port number or a service name. In case you don't specify whether you want to use TCP or UDP, sock uses the protocol associated with the specified service or falls back to TCP if both are possible. If the host name is omitted, "any" (for binding or listening) or "localhost" (for connecting) is assumed.
Use `echo -e "HELO `hostname -f`\nETRN `hostname -f`" | sock mail.server.name:smtp' to tell your mail-exchanger it should start sending all messages queued for you.
Use `sock -dl :7777 fortune' to establish a simple fortune cookie server.
Use `sock -e :7777' as a client for the above server.