@@ -24,6 +24,55 @@ There are four basic concrete server classes:
2424 :meth: `~BaseServer.server_activate `. The other parameters are passed to
2525 the :class: `BaseServer ` base class.
2626
27+ In addition to the methods and attributes inherited from :class: `BaseServer `,
28+ :class: `TCPServer ` provides:
29+
30+
31+ .. method :: fileno()
32+
33+ Return an integer file descriptor for the socket on which the server is
34+ listening. This function is most commonly passed to :mod: `selectors `, to
35+ allow monitoring multiple servers in the same process.
36+
37+
38+ .. method :: server_bind()
39+
40+ Called by the server's constructor to bind the socket to the desired address.
41+ May be overridden.
42+
43+
44+ .. attribute :: address_family
45+
46+ The family of protocols to which the server's socket belongs.
47+ Common examples are :const: `socket.AF_INET ` and :const: `socket.AF_UNIX `.
48+
49+
50+ .. attribute :: socket
51+
52+ The socket object on which the server will listen for incoming requests.
53+
54+
55+ .. attribute :: allow_reuse_address
56+
57+ Whether the server will allow the reuse of an address. This defaults to
58+ :const: `False `, and can be set in subclasses to change the policy.
59+
60+
61+ .. attribute :: request_queue_size
62+
63+ The size of the request queue. If it takes a long time to process a single
64+ request, any requests that arrive while the server is busy are placed into a
65+ queue, up to :attr: `request_queue_size ` requests. Once the queue is full,
66+ further requests from clients will get a "Connection denied" error. The default
67+ value is usually 5, but this can be overridden by subclasses.
68+
69+
70+ .. attribute :: socket_type
71+
72+ The type of socket used by the server; :const: `socket.SOCK_STREAM ` and
73+ :const: `socket.SOCK_DGRAM ` are two common values.
74+
75+
2776
2877.. class :: UDPServer(server_address, RequestHandlerClass, bind_and_activate=True)
2978
@@ -211,13 +260,6 @@ Server Objects
211260 :attr: `server_address ` and :attr: `RequestHandlerClass ` attributes.
212261
213262
214- .. method :: fileno()
215-
216- Return an integer file descriptor for the socket on which the server is
217- listening. This function is most commonly passed to :mod: `selectors `, to
218- allow monitoring multiple servers in the same process.
219-
220-
221263 .. method :: handle_request()
222264
223265 Process a single request. This function calls the following methods in
@@ -264,12 +306,6 @@ Server Objects
264306 Clean up the server. May be overridden.
265307
266308
267- .. attribute :: address_family
268-
269- The family of protocols to which the server's socket belongs.
270- Common examples are :const: `socket.AF_INET ` and :const: `socket.AF_UNIX `.
271-
272-
273309 .. attribute :: RequestHandlerClass
274310
275311 The user-provided request handler class; an instance of this class is created
@@ -285,36 +321,10 @@ Server Objects
285321 the address, and an integer port number: ``('127.0.0.1', 80) ``, for example.
286322
287323
288- .. attribute :: socket
289-
290- The socket object on which the server will listen for incoming requests.
291-
292-
293324 The server classes support the following class variables:
294325
295326 .. XXX should class variables be covered before instance variables, or vice versa?
296327
297- .. attribute :: allow_reuse_address
298-
299- Whether the server will allow the reuse of an address. This defaults to
300- :const: `False `, and can be set in subclasses to change the policy.
301-
302-
303- .. attribute :: request_queue_size
304-
305- The size of the request queue. If it takes a long time to process a single
306- request, any requests that arrive while the server is busy are placed into a
307- queue, up to :attr: `request_queue_size ` requests. Once the queue is full,
308- further requests from clients will get a "Connection denied" error. The default
309- value is usually 5, but this can be overridden by subclasses.
310-
311-
312- .. attribute :: socket_type
313-
314- The type of socket used by the server; :const: `socket.SOCK_STREAM ` and
315- :const: `socket.SOCK_DGRAM ` are two common values.
316-
317-
318328 .. attribute :: timeout
319329
320330 Timeout duration, measured in seconds, or :const: `None ` if no timeout is
@@ -341,6 +351,10 @@ Server Objects
341351 socket object to be used to communicate with the client, and the client's
342352 address.
343353
354+ An implementation of :meth: `get_request ` is provided by :class: `TCPServer `.
355+ Other classes which inherit from :class: `BaseServer ` directly must provide
356+ their own implementation.
357+
344358
345359 .. method :: handle_error(request, client_address)
346360
@@ -382,12 +396,6 @@ Server Objects
382396 on the server's socket. May be overridden.
383397
384398
385- .. method :: server_bind()
386-
387- Called by the server's constructor to bind the socket to the desired address.
388- May be overridden.
389-
390-
391399 .. method :: verify_request(request, client_address)
392400
393401 Must return a Boolean value; if the value is :const: `True `, the request will
@@ -697,4 +705,3 @@ The output of the example should look something like this:
697705 The :class: `ForkingMixIn ` class is used in the same way, except that the server
698706will spawn a new process for each request.
699707Available only on POSIX platforms that support :func: `~os.fork `.
700-
0 commit comments