FAUCET(1)
π FAUCET(1) β faucet π
okay bestie, welcome to the General Commands Manual! this is the tea on faucet, and we're rolling with netpipes 4.2. no cap, it's giving network pipes with main character energy. π
β¨
β¨ NAME β¨
faucet β a fixture for a BSD network pipe π
netpipes 4.2
fr fr, that's the whole name. periodt.
π SYNOPSIS π
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][1][q][u][d][s]] [-p foreign-port] [-h
foreign-host] [-H local-host] command args
πΈ DESCRIPTION πΈ
faucet is literally trying to give you pipes over the network, bestie. it behaves as the server end of a server-client connection. when you use it with hose(1), it can function as a replacement for
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, and --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 info. π«
π OPTIONS π
--onceβ if this flag is specified,faucetwillexec(2)the command instead offork(2)ing andexec(2)ing.--oncemeans the network pipe is only good for one shot. π―--verboseβ tellsfaucetto print information about connecting hosts. this info includes the numeric host address, host names, and foreign port numbers. π--quietβ tellsfaucetto NOT print such info.--quietis the default. π€«--unixβ says theportis not an internet port number or service name, but instead it's a file name for a UNIX domain socket. π¦--foreignhost addrβ saysfaucetshould reject all connections that do not come from the host machine. π«--foreignport portβ saysfaucetshould reject all connections that are not bound on their local machine to theportargument. π«
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 /etc/host.conf anyway. π
--localhost addrβ says 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β saysfaucetshould disassociate from the controlling terminal once it has started listening on the socket. this is done using thesetsid()system call. if you don't havesetsidon your system, it uses the standard ``close all file descriptors, ioctl TIOCNOTTY, fork() and parent exit'' sequence. π»--shutdown (r|w)β used to turn the (normally) bi-directional socket into a uni-directional one. if theris present, thenfaucetwill 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 thewis present, thenfaucetwill 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--errflags. 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β causesfaucetto wait for one child to finish before accepting any more connections. serialization is a very crude form of critical-section management. π¦--pidfile filenameβ commandsfaucetto write its process id intofilename. this is useful whenfaucetis part of a larger system and a controlling process might want to kill thefaucet.--pidfilefunctions properly when using the--daemonoption. π--noreuseaddrβ by default,faucetperforms 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 thelisten(2)system call. the default is5. π
π SHORT FLAGS π
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's the correspondence chart, bestie:
iβinoβouteβerr#nβfdnvβverbose1βonceqβquietuβunixdβdaemonsβserialpβforeignporthβforeignhostHβ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 appear.
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 -out. π‘
π EXAMPLES π
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 becomes unavailable. π¦
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'
π SEE ALSO π
netpipes (1), hose (1), sockdown (1), getpeername (1), socket (2), bind (2), listen (2), accept (2), shutdown (2), services (5), gethostbyaddr (3)
π BUGS π
there is a problem with almost every OS I have used faucet on. ports are sometimes not recycled swiftly enough. if you kill one faucet and try to start another that wants to listen on the same port you will often see pre-4.1 faucets print the following warning over and over again:
faucet: Address 3000 in use, sleeping 10.
faucet: Trying again . . .
but you won't actually be able to connect(2) to that port (with hose(1), for example) because you'll get a ``connection refused''. π
there was also an experimental Linux kernel that NEVER recycled ports (I quickly switched back to my old kernel). π
I have been informed that this is a side-effect of the TCP specification and that I should use the SO_REUSEADDR option to work around it, so I do. β
π NOTES π
doubtless there are bugs in this program, especially in the unix domain socket portions. I welcome problem reports and would like to make these programs as "clean" (no leftover files, sockets) as possible. π§
4.1 added --backlog and --noreuseaddr. --noreuseaddr reflects the fact that 4.1 also added the SO_REUSEADDR socket option as the default. π
4.0 made the full-word arguments use -- like many GNU programs. they are still available with a single - for backward-compatibility. π°οΈ
3.1 added the single-character flags and the -pidfile option. it also switched to the setsid(2) system call to detach itself from the process group for the -daemon flag. I've been hacking at UNIX for years, but there are still some things that I never really learned, and others that have been changing. I need to buy a book. π
Release 2.3 added support for multi-homed hosts: hosts with multiple internet numbers (such as gateways). before this faucet assumed that the first internet number that gethostbyname returned was the only one. --foreignhost authentication was weakened by this inadequacy so I beefed up the algorithms. --foreignhost will accept a connection from any of the internet numbers associated with the host name. π
π CREDITS π
okay bestie, this part is the author's lil gratitude dump and it's giving iconic. π
- Huge slay to Steve Clift <clift@ml.csiro.au> for the SGI (SysV) patches. π«Ά
- So many people complained about the old way of specifying the command, and honestly? fair. Thanks to whoever gave the alternative that's now implemented β it's much better. β¨
- Randy Fischer <fischer@ucet.ufl.edu> finally prodded the author into fixing the old lame non-handling of multi-homed host. no cap, finally. π
- Thanks to every single person who suggested using
setsid()for-daemonmode. y'all ate. π - Shoutout to the Spring 1996 UF CIS consulting staff <consult@cis.ufl.edu> for pointing out the
sys_errlist[]declaration conflict on FreeBSD. and sometimes the author hates Sun Microsystems, periodt. π - Thanks to Daniel O'Connor <doconnor@adam.ist.flinders.edu.au> for suggesting the
-pidfileflag. king behavior. π - Big big thanks to Joe Traister <traister@gate.net> for his signal handling patches,
strerrorsurrogate, and other assorted hacks. we love a multi-talented icon. π - Thanks to Thomas A. Endo <tendo@netcom.com> for dropping an
SO_REUSEADDRpatch right in the author's lap. otherwise it wouldn't have gotten handled till 2001. literally. π
π COPYRIGHT π
Copyright (C) 1992-98 Robert Forsman π
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. π
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. π
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. β¨
π AUTHOR π
Robert Forsman thoth@purplefrog.com Purple Frog Software http://web.purplefrog.com/~thoth/
and that's the whole page, bestie. this manual page is FAUCET(1), dated October 28, 1998. periodt. π β¨
π¦ where this page comes from
- debian bookworm: netpipes 4.2-8+b1
- debian trixie: netpipes 4.2-8+b2
- ubuntu jammy: netpipes 4.2-8build1
- ubuntu noble: netpipes 4.2-8build1
- ubuntu questing: netpipes 4.2-8.1
- ubuntu resolute: netpipes 4.2-8.1build1
- ubuntu stonking: netpipes 4.2-8.1build1
- Copyright 1992-98 by Robert Forsman
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms