packages icon



 sock(1)                          sock-1.1                           sock(1)
 UCW Utilities                                                 UCW Utilities

                                12 June 2001



 NAME
      sock - simple socket interface for shell scripts

 SYNOPSIS
      sock [-dentuvx] ([-b <local>] <remote> | -l <local>) [<command>]

 DESCRIPTION
      sock is a simple program serving as an interface between its standard
      input/output streams and sockets, primarily intended to be used in
      shell scripts, but often useful interactively from the command line as
      well.

      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).


 ADDRESSES
      sock currently supports two address families: IP and UNIX.

      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.


 OPTIONS
      -d   Run as a daemon and run the <command> for each incoming
           connection instead of exiting after having served a single
           connection.

      -e   Terminate after receiving first EOF in any direction. Default
           behaviour is to wait for EOF in both directions. Please note that
           this has changed since version 1.0.




                                    - 1 -         Formatted:  April 18, 2024






 sock(1)                          sock-1.1                           sock(1)
 UCW Utilities                                                 UCW Utilities

                                12 June 2001



      -n   Avoid reverse DNS lookups in verbose mode.

      -t   Open a TCP socket.

      -u   Open a UDP socket.

      -v   Be verbose. The more -v's you give, the more verbose sock is.

      -x   Open a UNIX socket.


 EXAMPLES
      Use `sock :smtp' to talk with local mailer.

      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.


 AUTHOR
      sock has been written and is (at least sometimes) maintained by Martin
      Mares <mj@ucw.cz>.

























                                    - 2 -         Formatted:  April 18, 2024