This is the command faucet that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator
faucet - a fixture for a BSD network pipe
faucet port (--in|--out|--err|--fd n)+ [--once] [--verbose] [--quiet] [--unix]
[--foreignhost addr] [--foreignport port] [--localhost addr] [--serial] [--daemon]
[--shutdown (r|w) ] [--pidfile filename] [--noreuseaddr] [--backlog n]
[-[i][o][e][#3[,4[,5...]]][v][q][u][d][s]] [-p foreign-port] [-h foreign-host] [-H
local-host] command args
faucet attempts to provide the functionality of pipes over the network. It behaves as the
server end of a server-client connection. When used with hose(1) it can function as a
tar -cf - . | rsh other "cd destdir; tar -xf -"
faucet and hose are especially useful when you don't have easy non-interactive access to
the destination account (such as a root account where .rhosts are a bad idea).
faucet creates a BSD socket, binds it to the port specified on the command line, and
listens for connections.
Every time faucet gets a connection it exec(2)s command and its args with stdin, stdout,
stderr, and/or arbitrary file descriptors redirected according to the --in --out --err
--fd n flags. faucet also automagically shuts down the unused half of the connection if
only --in is specified or if only --out and/or --err are specified. See the --shutdown
option for more information.
If the --once flag is specified, faucet will exec(2) the command instead of fork(2)ing and
exec(2)ing. --once means that the network pipe is only good for one shot.
The --verbose flag specifies that faucet should print information about connecting hosts.
This information includes the numeric host address, host names, and foreign port numbers.
The --quiet flag specifies that faucet should NOT print such info. --quiet is the
The --unix flag specifies that the port is not an internet port number or service name,
but instead it is a file name for a UNIX domain socket.
The --foreignhost option specifies that faucet should reject all connections that do not
come from the host machine. Similarly --foreignport specifies that faucet should reject
all connections that are not bound on their local machine to the port argument. The above
two options allow a crude form of authentication. Note that on UNIX systems only root can
bind a socket to a port number below 1024.
Please do not be fooled into thinking this makes faucet secure. There are ways to spoof
IP numbers that have been known for years (but only publicized recently). I do think that
this method is safe from DNS spoofs, but you probably should have nospoof on in
--localhost specifies that the listening socket should be bound to a specific internet
address on this host. This is only useful on hosts with several internet numbers.
--daemon specifies that the faucet should disassociate from the controlling terminal once
it has started listening on the socket. This is done using the setsid() system call. If
you don't have setsid on your system, it uses the standard ``close all file descriptors,
ioctl TIOCNOTTY, fork() and parent exit'' sequence.
--shutdown is used to turn the (normally) bi-directional socket into a uni-directional one
If the `r' is present, then faucet will close half the connection to make it a read-only
socket. If we try to write, it will fail. If the remote connection tries to read, it
will percieve the socket as closed. If instead the `w' is present, then faucet will close
the other half of the connection to make it a write-only socket. If we try to read, we
will percieve the socket as closed. If the remote connection tries to write, it will
fail. The default behavior is to leave both halves open, however the shutdown of half of
the connection is automagically done by certain combinations of the --in, --out, and --err
flags. To suppress their automagic behavior you can use (respectively) --fd 0, --fd 1,
and --fd 2.
--shutdown may not be used with some internet servers (such as certain httpds) because
they interpret the closing of one half of the connection as a close on the entire
connection. This warning applies to --in, --out, and --err.
--serial causes faucet to wait for one child to finish before accepting any more
connections. Serialization is a very crude form of critical-section management.
--pidfile filename commands faucet to write its process id into filename. This is useful
when faucet is part of a larger system and a controlling process might want to kill the
faucet. --pidfile functions properly when using the --daemon option.
By default, faucet performs a
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR...)
which prevents the ``Address in use'' problem that ``plagued'' netpipes versions 4.0 and
earlier. --noreuseaddr tells faucet to skip that system call, and revert to pre-4.1
behavior. Without this call, the socket is not always available for immediate reuse after
the faucet exits.
--backlog n allows you to specify the second parameter to the listen(2) system call. The
default is 5.
To reduce the typing requirements for arguments (and to pay homage to the age-old
tradition of UNIX cryptotaxonomy) I have added some short forms of the flags. Here is a
│Short │ Long │
│ i │ in │
│ o │ out │
│ e │ err │
│ #n │ fdn │
│ v │ verbose │
│ 1 │ once │
│ q │ quiet │
│ u │ unix │
│ d │ daemon │
│ s │ serial │
│ p │ foreignport │
│ h │ foreignhost │
│ H │ localhost │
For example, the following command
example$ faucet 3000 --out --verbose --once --foreignhost client echo blah
could be written
example$ faucet 3000 -ov1h client echo blah
The -p, -h, and -H flags take an argument, but the flags may be grouped into one argument.
They then grab the arguments they need from the command line in the order the flags
example$ faucet 3000 -hpHov1 client 2999 example-le2 echo blah
Whereas each --fd word flag required an individual descriptor, the -# character flag can
take multiple descriptors. The following are equivalent:
example$ faucet 3000 --fd 0 --fd 1 --verbose --once echo blah
example$ faucet 3000 -#0,1v --once echo blah
example$ faucet 3000 -v1#0,1 echo blah
example$ faucet 3000 -#0,1v1 echo blah
Note that you have to pay attention when using the -# character flag and the -1 character
flag in the same argument. Also, remember the special shutdown(2) semantics of -in and
This creates a TCP-IP socket on the local machine bound to port 3000.
example$ faucet 3000 --out --verbose tar -cf - .
Every time some process (from any machine) attempts to connect to port 3000 on this
machine the faucet program will fork(2) a process and the child will exec(2) a
tar -cf - .
The --out option means that the output of the child process will have been redirected into
the new socket retrieved by the accept(2) call. --verbose means that faucet will print
information about each new connection.
This creates a UNIX domain socket in the current directory
example$ faucet u-socket --out --err --once --unix csh -c \
"dd if=angio.pgm | funky.perl.script"
The --out --err option means that stdout and stderr will be redirected in the child
process. The --once option means that the faucet will not fork(2), but exec(2) the
process so that only the first process can connect to the u-socket before the faucet
This example listens on a socket until the first connection comes through. It then spawns
a bidirectional copy that is similar to hose -slave.
faucet 3000 -1v --fd 3 sh -c 'cat <&3 & cat >&3 ; sockdown 3'
Use faucet online using onworks.net services