about summary refs log tree commit diff
path: root/Doc/Zsh/mod_socket.yo
blob: 78d9254e8dc0d3a575a334683eaa092cb70aa524 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
COMMENT(!MOD!zsh/net/socket
Manipulation of Unix domain sockets
!MOD!)
The tt(zsh/net/socket) module makes available one builtin command:

startitem()
findex(zsocket)
cindex(sockets)
cindex(sockets, Unix domain)
item(tt(zsocket) [ tt(-altv) ] [ tt(-d) var(fd) ] [ var(args) ])(
tt(zsocket) is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms.
)
enditem()

subsect(Outbound Connections)
cindex(sockets, outbound Unix domain)

startitem()
item(tt(zsocket) [ tt(-v) ] [ tt(-d) var(fd) ] var(filename))(
Open a new Unix domain connection to var(filename).
The shell parameter tt(REPLY) will be set to the file descriptor
associated with that connection.  Currently, only stream connections
are supported.

If tt(-d) is specified, its argument
will be taken as the target file descriptor for the
connection.

In order to elicit more verbose output, use tt(-v).

File descriptors can be closed with normal shell syntax when no longer
needed, for example:

example(exec {REPLY}>&-)
)
enditem()

subsect(Inbound Connections)
cindex(sockets, inbound Unix domain)

startitem()
item(tt(zsocket) tt(-l) [ tt(-v) ] [ tt(-d) var(fd) ] var(filename))(
tt(zsocket -l) will open a socket listening on var(filename).
The shell parameter tt(REPLY) will be set to the file descriptor
associated with that listener.  The file descriptor remains open in subshells
and forked external executables.

If tt(-d) is specified, its argument
will be taken as the target file descriptor for
the connection.

In order to elicit more verbose output, use tt(-v).
)
item(tt(zsocket) tt(-a) [ tt(-tv) ] [ tt(-d) var(targetfd) ] var(listenfd))(
tt(zsocket -a) will accept an incoming connection
to the socket associated with var(listenfd).
The shell parameter tt(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 tt(-d) is specified, its argument
will be taken as the target file descriptor for the
connection.

If tt(-t) is specified, tt(zsocket) will return
if no incoming connection is pending.  Otherwise
it will wait for one.

In order to elicit more verbose output, use tt(-v).
)
enditem()