SOCKET(1)
π SOCKET(1) π
okay bestie, welcome to socket, from the General Commands Manual section 1 (that's user commands, iykyk). this little icon is gonna make a TCP or UNIX domain socket and hook it straight up to your stdin and stdout. slay.
β¨ NAME β¨
socket β create a TCP or a UNIX domain socket and connect to stdin/out
πΈ SYNOPSIS πΈ
socket [ -bcfqrvw ] [ -p command ] [ -B local address ] host port
socket [ -bcfqrvw ] [ -p command ] /path
socket [ -bcfqrvw ] [ -p command ] [ -B local address ] -s [ -l ] port
socket [ -bcfqrvw ] [ -p command ] -s [ -l ] /path
π¦ DESCRIPTION π¦
so socket creates an Internet domain TCP socket or a UNIX domain stream socket, and then connects it to stdin and stdout. literally just wires it right up. π
the host argument can be an Internet number in dot-notation (like 130.149.28.10) or a domain name. if it's a domain name, it has to be resolvable to a valid Internet address with gethostbyname(3) β no cap, that's a requirement. π«Ά
the port argument can be a port number, or a service name that getservbyname(3) can map to a port number.
if you want a UNIX domain socket instead of an Internet socket, you just specify the path instead of an internet host (canonical domain named or dot-notated, either one). the hostname gets treated as a pathname if it contains at least a single slash β at least one slash, that's the vibe check. so if you wanna create or connect to a socket in the current directory, use ./filename to specify the connection point. periodt. π
β¨ OPTIONS β¨
-b(background) β the program forks itself into the background, detaches from its controlling tty, closes the file descriptors associated with the tty, and changes its current directory to the root directory. bye bestie, going ghost mode π»-B(local address) β this option specifies which local address to binded to when making a connection. (yes, the manpage really says "binded", we don't fix that, we respect the source π)-c(crlf) β Linefeed characters (LF) are converted to a Carriage Return Linefeed sequence (CRLF) when written to the socket. CRLF sequences read from the socket are converted to a single LF. it's giving translator energy π§-f(fork) β when a server connection has been accepted, a separate process is forked to handle the connection in background. multitasking queen π-l(loop) β (only valid with-s) after a connection has been closed, another connection is accepted. it never stops, iconic behavior β¨-p(program) β the specified command is executed for each connection. its standard input, standard output, and standard error channels are connected to the socket. command can be any shell command since it is passed to/bin/sh. π-q(quit) β the connection is closed when an end-of-file condition occurs on standard input. when stdin says "i'm done", we listen π-r(read only) β no data is read from standard input and written to the socket. we're just here to receive, lowkey πΈ-s(server) β a server socket is created. a hostname argument is not required of Internet sockets, only the port number β but a pathname is required for UNIX domain sockets. π-v(verbose) β messages about connections etc. are issued tostderr. it will tell you everything, main character energy fr fr π£οΈ-w(write only) β no data is read from the socket and written to the standard output. talk only, no listening π-versionβsocketprints its version ID and terminates. this must be the first argument to have an effect β put it anywhere else and it just does nothing, so don't play yourself β
π EXAMPLES π
the command
socket -v coma.cs.tu-berlin.de nntp
connects to the nntp port (port 119) of coma.cs.tu-berlin.de (130.149.28.10). π₯
the command
socket -sl 3425
creates a server socket on port 3425 on the local host and waits for a connection. after a connection has been closed, a new connection is accepted. π
the command
socket -wslqvp "echo Socket! " 1938
creates a server socket on port 1938 on the local host and waits for a connection. when a connection is accepted, the string "Socket!" is written to the socket. no data is read from the socket and written to the finger program. the connection is closed when an end-of-file condition at the standard output of the program occurs. then a new connection is accepted. π¦
π DIAGNOSTICS π
lots of diagnostics for failed system calls. (yes. "lots." that's the whole description. we love a vague queen.)
unknown host hostβ host's address could not be resolved. πSignal signal caught, exitingβsocketexits on any signal other thanSIGTSTP,SIGCONT,SIGCLD,SIGQUIT. those four it tolerates, everything else is bye bye π«Ά
a non-zero exit code is returned if socket terminates due to an error condition or a signal.
π SEE ALSO π
ip(7), tcp(7), unix(7), accept(2), bind(2), listen(2), connect(2), socket(2), gethostbyname(3), getservbyname(3)
π BUGS π
socket -pterminates due to aSIGPIPEsignal when there is more data from the socket available than the executed program wants to read. so if the program is a picky eater, everything explodes. not cute. π- please report any other bugs to the author.
β VERSION β
this manual page describes Socket-1.1.
π AUTHOR π
Juergen Nickelsen <nickel@cs.tu-berlin.de>
and that's the whole page bestie!! written Aug 6, 1992 (a whole legend, ancient and still iconic), from the General Commands Manual, version SOCKET(1). go make some sockets, you got this πβ¨π¦
π¦ where this page comes from
- debian trixie: socket 1.1-10.1
- ubuntu jammy: socket 1.1-10build1
- ubuntu noble: socket 1.1-10.1
- ubuntu questing: socket 1.1-10.1
- ubuntu resolute: socket 1.1-10.1build1
- ubuntu stonking: socket 1.1-10.1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms