The zsh/net/socket
module makes available one builtin command:
zsocket
[ -altv
] [ -d
fd ] [ args ]zsocket
is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms.
zsocket
[ -v
] [ -d
fd ] filenameOpen a new Unix domain connection to filename.
The shell parameter REPLY
will be set to the file descriptor
associated with that connection. Currently, only stream connections
are supported.
If -d
is specified, its argument
will be taken as the target file descriptor for the
connection.
In order to elicit more verbose output, use -v
.
File descriptors can be closed with normal shell syntax when no longer needed, for example:
exec {REPLY}>&-
zsocket
-l
[ -v
] [ -d
fd ] filenamezsocket -l
will open a socket listening on filename.
The shell parameter REPLY
will be set to the file descriptor
associated with that listener. The file descriptor remains open in subshells
and forked external executables.
If -d
is specified, its argument
will be taken as the target file descriptor for
the connection.
In order to elicit more verbose output, use -v
.
zsocket
-a
[ -tv
] [ -d
targetfd ] listenfdzsocket -a
will accept an incoming connection
to the socket associated with listenfd.
The shell parameter REPLY
will
be set to the file descriptor associated with
the inbound connection. The file descriptor remains open in subshells
and forked external executables.
If -d
is specified, its argument
will be taken as the target file descriptor for the
connection.
If -t
is specified, zsocket
will return
if no incoming connection is pending. Otherwise
it will wait for one.
In order to elicit more verbose output, use -v
.