summaryrefslogtreecommitdiff
path: root/tcpserver.1
blob: 04b10f959d2ec2877e28342cc351df948826cc1c (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
.TH tcpserver 1
.SH NAME
tcpserver \- accept incoming TCP connections
.SH SYNOPSIS
.B tcpserver
[
.B \-1pPhHrRoOdDqQv
]
[
.B \-c\fIlimit
]
[
.B \-x\fIrules.cdb
]
[
.B \-B\fIbanner
]
[
.B \-g\fIgid
]
[
.B \-u\fIuid
]
[
.B \-b\fIbacklog
]
[
.B \-l\fIlocalname
]
[
.B \-t\fItimeout
]
.I host
.I port
.I program
[
.I arg ...
]
.SH DESCRIPTION
.B tcpserver
waits for connections from TCP clients.
For each connection, it runs
.I program
with the given arguments,
with descriptor 0 reading from the network
and descriptor 1 writing to the network.

The server's address is given by
.I host
and
.IR port .
.I host
can be 0, allowing connections from any host;
or a particular IP address,
allowing connections only to that address;
or a host name, allowing connections to the first IP address
for that host.
.I port
may be a numeric port number
or a port name.
If
.I port
is 0,
.B tcpserver
will choose a free port.

.B tcpserver
sets up several environment variables,
as described in
.B tcp-environ(5).

.B tcpserver
exits when it receives SIGTERM.
.SH "OPTIONS"
.TP
.B \-c\fIlimit
Do not handle more than
.I limit
simultaneous connections.
If there are
.I limit
simultaneous copies of
.I program
running, defer acceptance of a new connection
until one copy finishes.
.I limit
must be a positive integer.
Default: 40.
.TP
.B \-x\fIrules.cdb
Follow the rules compiled into
.I rules.cdb
by
.BR tcprules .
These rules may specify setting environment variables
or rejecting connections from bad sources.

.B tcpserver
does not read
.I rules.cdb
into memory;
you can rerun
.B tcprules
to change
.BR tcpserver 's
behavior on the fly.
.TP
.B \-B\fIbanner
Write
.I banner
to the network immediately after each connection is made.
.B tcpserver
writes
.I banner
before looking up
.BR TCPREMOTEHOST ,
before looking up
.BR TCPREMOTEINFO ,
and before checking
.IR rules.cdb .

This feature can be used to reduce latency in protocols
where the client waits for a greeting from the server.
.TP
.B \-g\fIgid
Switch group ID to
.I gid
after preparing to receive connections.
.I gid
must be a positive integer.
.TP
.B \-u\fIuid
Switch user ID to 
.I uid
after preparing to receive connections.
.I uid
must be a positive integer.
.TP
.B \-1
After preparing to receive connections,
print the local port number to standard output.
.TP
.B \-b\fIbacklog
Allow up to
.I backlog
simultaneous SYN_RECEIVEDs.
Default: 20.
On some systems,
.I backlog
is silently limited to 5.
See
.BR listen (2)
for more details.
.TP
.B \-o
Leave IP options alone.
If the client is sending packets along an IP source route,
send packets back along the same route.
.TP
.B \-O
(Default.)
Kill IP options.
A client can still use source routing to connect and to send data,
but packets will be sent back along the default route.
.TP
.B \-d
(Default.)
Delay sending data for a fraction of a second whenever the
remote host is responding slowly,
to make better use of the network.
.TP
.B \-D
Never delay sending data;
enable TCP_NODELAY.
This is appropriate for interactive connections.
.TP
.B \-q
Quiet.
Do not print any messages.
.TP
.B \-Q
(Default.)
Print error messages.
.TP
.B \-v
Verbose.
Print all available messages.
.SH "DATA-GATHERING OPTIONS"
.TP
.B \-p
Paranoid.
After looking up the remote host name,
look up the IP addresses for that name,
and make sure one of them matches
.BR TCPREMOTEIP .
If none of them do,
unset
.BR TCPREMOTEHOST .
.TP
.B \-P
(Default.)
Not paranoid.
.TP
.B \-h
(Default.)
Look up the remote host name and set
.BR TCPREMOTEHOST .
.TP
.B \-H
Do not look up the remote host name.
.TP
.B \-l\fIlocalname
Do not look up the local host name;
use
.I localname
for
.BR TCPLOCALHOST .
.TP
.B \-r
(Default.)
Attempt to obtain
.B TCPREMOTEINFO
from the remote host.
.TP
.B \-R
Do not attempt to obtain
.B TCPREMOTEINFO
from the remote host.
.TP
.B \-t\fItimeout
Give up on the 
.B TCPREMOTEINFO
connection attempt
after
.I timeout
seconds. Default: 26.
.SH "SEE ALSO"
argv0(1),
fixcr(1),
recordio(1),
tcpclient(1),
tcprules(1),
listen(2),
tcp-environ(5)