Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3....
File: socketserver.py
"""Generic socket server classes.
[0] Fix | Delete
[1] Fix | Delete
This module tries to capture the various aspects of defining a server:
[2] Fix | Delete
[3] Fix | Delete
For socket-based servers:
[4] Fix | Delete
[5] Fix | Delete
- address family:
[6] Fix | Delete
- AF_INET{,6}: IP (Internet Protocol) sockets (default)
[7] Fix | Delete
- AF_UNIX: Unix domain sockets
[8] Fix | Delete
- others, e.g. AF_DECNET are conceivable (see <socket.h>
[9] Fix | Delete
- socket type:
[10] Fix | Delete
- SOCK_STREAM (reliable stream, e.g. TCP)
[11] Fix | Delete
- SOCK_DGRAM (datagrams, e.g. UDP)
[12] Fix | Delete
[13] Fix | Delete
For request-based servers (including socket-based):
[14] Fix | Delete
[15] Fix | Delete
- client address verification before further looking at the request
[16] Fix | Delete
(This is actually a hook for any processing that needs to look
[17] Fix | Delete
at the request before anything else, e.g. logging)
[18] Fix | Delete
- how to handle multiple requests:
[19] Fix | Delete
- synchronous (one request is handled at a time)
[20] Fix | Delete
- forking (each request is handled by a new process)
[21] Fix | Delete
- threading (each request is handled by a new thread)
[22] Fix | Delete
[23] Fix | Delete
The classes in this module favor the server type that is simplest to
[24] Fix | Delete
write: a synchronous TCP/IP server. This is bad class design, but
[25] Fix | Delete
saves some typing. (There's also the issue that a deep class hierarchy
[26] Fix | Delete
slows down method lookups.)
[27] Fix | Delete
[28] Fix | Delete
There are five classes in an inheritance diagram, four of which represent
[29] Fix | Delete
synchronous servers of four types:
[30] Fix | Delete
[31] Fix | Delete
+------------+
[32] Fix | Delete
| BaseServer |
[33] Fix | Delete
+------------+
[34] Fix | Delete
|
[35] Fix | Delete
v
[36] Fix | Delete
+-----------+ +------------------+
[37] Fix | Delete
| TCPServer |------->| UnixStreamServer |
[38] Fix | Delete
+-----------+ +------------------+
[39] Fix | Delete
|
[40] Fix | Delete
v
[41] Fix | Delete
+-----------+ +--------------------+
[42] Fix | Delete
| UDPServer |------->| UnixDatagramServer |
[43] Fix | Delete
+-----------+ +--------------------+
[44] Fix | Delete
[45] Fix | Delete
Note that UnixDatagramServer derives from UDPServer, not from
[46] Fix | Delete
UnixStreamServer -- the only difference between an IP and a Unix
[47] Fix | Delete
stream server is the address family, which is simply repeated in both
[48] Fix | Delete
unix server classes.
[49] Fix | Delete
[50] Fix | Delete
Forking and threading versions of each type of server can be created
[51] Fix | Delete
using the ForkingMixIn and ThreadingMixIn mix-in classes. For
[52] Fix | Delete
instance, a threading UDP server class is created as follows:
[53] Fix | Delete
[54] Fix | Delete
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
[55] Fix | Delete
[56] Fix | Delete
The Mix-in class must come first, since it overrides a method defined
[57] Fix | Delete
in UDPServer! Setting the various member variables also changes
[58] Fix | Delete
the behavior of the underlying server mechanism.
[59] Fix | Delete
[60] Fix | Delete
To implement a service, you must derive a class from
[61] Fix | Delete
BaseRequestHandler and redefine its handle() method. You can then run
[62] Fix | Delete
various versions of the service by combining one of the server classes
[63] Fix | Delete
with your request handler class.
[64] Fix | Delete
[65] Fix | Delete
The request handler class must be different for datagram or stream
[66] Fix | Delete
services. This can be hidden by using the request handler
[67] Fix | Delete
subclasses StreamRequestHandler or DatagramRequestHandler.
[68] Fix | Delete
[69] Fix | Delete
Of course, you still have to use your head!
[70] Fix | Delete
[71] Fix | Delete
For instance, it makes no sense to use a forking server if the service
[72] Fix | Delete
contains state in memory that can be modified by requests (since the
[73] Fix | Delete
modifications in the child process would never reach the initial state
[74] Fix | Delete
kept in the parent process and passed to each child). In this case,
[75] Fix | Delete
you can use a threading server, but you will probably have to use
[76] Fix | Delete
locks to avoid two requests that come in nearly simultaneous to apply
[77] Fix | Delete
conflicting changes to the server state.
[78] Fix | Delete
[79] Fix | Delete
On the other hand, if you are building e.g. an HTTP server, where all
[80] Fix | Delete
data is stored externally (e.g. in the file system), a synchronous
[81] Fix | Delete
class will essentially render the service "deaf" while one request is
[82] Fix | Delete
being handled -- which may be for a very long time if a client is slow
[83] Fix | Delete
to read all the data it has requested. Here a threading or forking
[84] Fix | Delete
server is appropriate.
[85] Fix | Delete
[86] Fix | Delete
In some cases, it may be appropriate to process part of a request
[87] Fix | Delete
synchronously, but to finish processing in a forked child depending on
[88] Fix | Delete
the request data. This can be implemented by using a synchronous
[89] Fix | Delete
server and doing an explicit fork in the request handler class
[90] Fix | Delete
handle() method.
[91] Fix | Delete
[92] Fix | Delete
Another approach to handling multiple simultaneous requests in an
[93] Fix | Delete
environment that supports neither threads nor fork (or where these are
[94] Fix | Delete
too expensive or inappropriate for the service) is to maintain an
[95] Fix | Delete
explicit table of partially finished requests and to use a selector to
[96] Fix | Delete
decide which request to work on next (or whether to handle a new
[97] Fix | Delete
incoming request). This is particularly important for stream services
[98] Fix | Delete
where each client can potentially be connected for a long time (if
[99] Fix | Delete
threads or subprocesses cannot be used).
[100] Fix | Delete
[101] Fix | Delete
Future work:
[102] Fix | Delete
- Standard classes for Sun RPC (which uses either UDP or TCP)
[103] Fix | Delete
- Standard mix-in classes to implement various authentication
[104] Fix | Delete
and encryption schemes
[105] Fix | Delete
[106] Fix | Delete
XXX Open problems:
[107] Fix | Delete
- What to do with out-of-band data?
[108] Fix | Delete
[109] Fix | Delete
BaseServer:
[110] Fix | Delete
- split generic "request" functionality out into BaseServer class.
[111] Fix | Delete
Copyright (C) 2000 Luke Kenneth Casson Leighton <lkcl@samba.org>
[112] Fix | Delete
[113] Fix | Delete
example: read entries from a SQL database (requires overriding
[114] Fix | Delete
get_request() to return a table entry from the database).
[115] Fix | Delete
entry is processed by a RequestHandlerClass.
[116] Fix | Delete
[117] Fix | Delete
"""
[118] Fix | Delete
[119] Fix | Delete
# Author of the BaseServer patch: Luke Kenneth Casson Leighton
[120] Fix | Delete
[121] Fix | Delete
__version__ = "0.4"
[122] Fix | Delete
[123] Fix | Delete
[124] Fix | Delete
import socket
[125] Fix | Delete
import selectors
[126] Fix | Delete
import os
[127] Fix | Delete
import sys
[128] Fix | Delete
import threading
[129] Fix | Delete
from io import BufferedIOBase
[130] Fix | Delete
from time import monotonic as time
[131] Fix | Delete
[132] Fix | Delete
__all__ = ["BaseServer", "TCPServer", "UDPServer",
[133] Fix | Delete
"ThreadingUDPServer", "ThreadingTCPServer",
[134] Fix | Delete
"BaseRequestHandler", "StreamRequestHandler",
[135] Fix | Delete
"DatagramRequestHandler", "ThreadingMixIn"]
[136] Fix | Delete
if hasattr(os, "fork"):
[137] Fix | Delete
__all__.extend(["ForkingUDPServer","ForkingTCPServer", "ForkingMixIn"])
[138] Fix | Delete
if hasattr(socket, "AF_UNIX"):
[139] Fix | Delete
__all__.extend(["UnixStreamServer","UnixDatagramServer",
[140] Fix | Delete
"ThreadingUnixStreamServer",
[141] Fix | Delete
"ThreadingUnixDatagramServer"])
[142] Fix | Delete
[143] Fix | Delete
# poll/select have the advantage of not requiring any extra file descriptor,
[144] Fix | Delete
# contrarily to epoll/kqueue (also, they require a single syscall).
[145] Fix | Delete
if hasattr(selectors, 'PollSelector'):
[146] Fix | Delete
_ServerSelector = selectors.PollSelector
[147] Fix | Delete
else:
[148] Fix | Delete
_ServerSelector = selectors.SelectSelector
[149] Fix | Delete
[150] Fix | Delete
[151] Fix | Delete
class BaseServer:
[152] Fix | Delete
[153] Fix | Delete
"""Base class for server classes.
[154] Fix | Delete
[155] Fix | Delete
Methods for the caller:
[156] Fix | Delete
[157] Fix | Delete
- __init__(server_address, RequestHandlerClass)
[158] Fix | Delete
- serve_forever(poll_interval=0.5)
[159] Fix | Delete
- shutdown()
[160] Fix | Delete
- handle_request() # if you do not use serve_forever()
[161] Fix | Delete
- fileno() -> int # for selector
[162] Fix | Delete
[163] Fix | Delete
Methods that may be overridden:
[164] Fix | Delete
[165] Fix | Delete
- server_bind()
[166] Fix | Delete
- server_activate()
[167] Fix | Delete
- get_request() -> request, client_address
[168] Fix | Delete
- handle_timeout()
[169] Fix | Delete
- verify_request(request, client_address)
[170] Fix | Delete
- server_close()
[171] Fix | Delete
- process_request(request, client_address)
[172] Fix | Delete
- shutdown_request(request)
[173] Fix | Delete
- close_request(request)
[174] Fix | Delete
- service_actions()
[175] Fix | Delete
- handle_error()
[176] Fix | Delete
[177] Fix | Delete
Methods for derived classes:
[178] Fix | Delete
[179] Fix | Delete
- finish_request(request, client_address)
[180] Fix | Delete
[181] Fix | Delete
Class variables that may be overridden by derived classes or
[182] Fix | Delete
instances:
[183] Fix | Delete
[184] Fix | Delete
- timeout
[185] Fix | Delete
- address_family
[186] Fix | Delete
- socket_type
[187] Fix | Delete
- allow_reuse_address
[188] Fix | Delete
[189] Fix | Delete
Instance variables:
[190] Fix | Delete
[191] Fix | Delete
- RequestHandlerClass
[192] Fix | Delete
- socket
[193] Fix | Delete
[194] Fix | Delete
"""
[195] Fix | Delete
[196] Fix | Delete
timeout = None
[197] Fix | Delete
[198] Fix | Delete
def __init__(self, server_address, RequestHandlerClass):
[199] Fix | Delete
"""Constructor. May be extended, do not override."""
[200] Fix | Delete
self.server_address = server_address
[201] Fix | Delete
self.RequestHandlerClass = RequestHandlerClass
[202] Fix | Delete
self.__is_shut_down = threading.Event()
[203] Fix | Delete
self.__shutdown_request = False
[204] Fix | Delete
[205] Fix | Delete
def server_activate(self):
[206] Fix | Delete
"""Called by constructor to activate the server.
[207] Fix | Delete
[208] Fix | Delete
May be overridden.
[209] Fix | Delete
[210] Fix | Delete
"""
[211] Fix | Delete
pass
[212] Fix | Delete
[213] Fix | Delete
def serve_forever(self, poll_interval=0.5):
[214] Fix | Delete
"""Handle one request at a time until shutdown.
[215] Fix | Delete
[216] Fix | Delete
Polls for shutdown every poll_interval seconds. Ignores
[217] Fix | Delete
self.timeout. If you need to do periodic tasks, do them in
[218] Fix | Delete
another thread.
[219] Fix | Delete
"""
[220] Fix | Delete
self.__is_shut_down.clear()
[221] Fix | Delete
try:
[222] Fix | Delete
# XXX: Consider using another file descriptor or connecting to the
[223] Fix | Delete
# socket to wake this up instead of polling. Polling reduces our
[224] Fix | Delete
# responsiveness to a shutdown request and wastes cpu at all other
[225] Fix | Delete
# times.
[226] Fix | Delete
with _ServerSelector() as selector:
[227] Fix | Delete
selector.register(self, selectors.EVENT_READ)
[228] Fix | Delete
[229] Fix | Delete
while not self.__shutdown_request:
[230] Fix | Delete
ready = selector.select(poll_interval)
[231] Fix | Delete
# bpo-35017: shutdown() called during select(), exit immediately.
[232] Fix | Delete
if self.__shutdown_request:
[233] Fix | Delete
break
[234] Fix | Delete
if ready:
[235] Fix | Delete
self._handle_request_noblock()
[236] Fix | Delete
[237] Fix | Delete
self.service_actions()
[238] Fix | Delete
finally:
[239] Fix | Delete
self.__shutdown_request = False
[240] Fix | Delete
self.__is_shut_down.set()
[241] Fix | Delete
[242] Fix | Delete
def shutdown(self):
[243] Fix | Delete
"""Stops the serve_forever loop.
[244] Fix | Delete
[245] Fix | Delete
Blocks until the loop has finished. This must be called while
[246] Fix | Delete
serve_forever() is running in another thread, or it will
[247] Fix | Delete
deadlock.
[248] Fix | Delete
"""
[249] Fix | Delete
self.__shutdown_request = True
[250] Fix | Delete
self.__is_shut_down.wait()
[251] Fix | Delete
[252] Fix | Delete
def service_actions(self):
[253] Fix | Delete
"""Called by the serve_forever() loop.
[254] Fix | Delete
[255] Fix | Delete
May be overridden by a subclass / Mixin to implement any code that
[256] Fix | Delete
needs to be run during the loop.
[257] Fix | Delete
"""
[258] Fix | Delete
pass
[259] Fix | Delete
[260] Fix | Delete
# The distinction between handling, getting, processing and finishing a
[261] Fix | Delete
# request is fairly arbitrary. Remember:
[262] Fix | Delete
#
[263] Fix | Delete
# - handle_request() is the top-level call. It calls selector.select(),
[264] Fix | Delete
# get_request(), verify_request() and process_request()
[265] Fix | Delete
# - get_request() is different for stream or datagram sockets
[266] Fix | Delete
# - process_request() is the place that may fork a new process or create a
[267] Fix | Delete
# new thread to finish the request
[268] Fix | Delete
# - finish_request() instantiates the request handler class; this
[269] Fix | Delete
# constructor will handle the request all by itself
[270] Fix | Delete
[271] Fix | Delete
def handle_request(self):
[272] Fix | Delete
"""Handle one request, possibly blocking.
[273] Fix | Delete
[274] Fix | Delete
Respects self.timeout.
[275] Fix | Delete
"""
[276] Fix | Delete
# Support people who used socket.settimeout() to escape
[277] Fix | Delete
# handle_request before self.timeout was available.
[278] Fix | Delete
timeout = self.socket.gettimeout()
[279] Fix | Delete
if timeout is None:
[280] Fix | Delete
timeout = self.timeout
[281] Fix | Delete
elif self.timeout is not None:
[282] Fix | Delete
timeout = min(timeout, self.timeout)
[283] Fix | Delete
if timeout is not None:
[284] Fix | Delete
deadline = time() + timeout
[285] Fix | Delete
[286] Fix | Delete
# Wait until a request arrives or the timeout expires - the loop is
[287] Fix | Delete
# necessary to accommodate early wakeups due to EINTR.
[288] Fix | Delete
with _ServerSelector() as selector:
[289] Fix | Delete
selector.register(self, selectors.EVENT_READ)
[290] Fix | Delete
[291] Fix | Delete
while True:
[292] Fix | Delete
ready = selector.select(timeout)
[293] Fix | Delete
if ready:
[294] Fix | Delete
return self._handle_request_noblock()
[295] Fix | Delete
else:
[296] Fix | Delete
if timeout is not None:
[297] Fix | Delete
timeout = deadline - time()
[298] Fix | Delete
if timeout < 0:
[299] Fix | Delete
return self.handle_timeout()
[300] Fix | Delete
[301] Fix | Delete
def _handle_request_noblock(self):
[302] Fix | Delete
"""Handle one request, without blocking.
[303] Fix | Delete
[304] Fix | Delete
I assume that selector.select() has returned that the socket is
[305] Fix | Delete
readable before this function was called, so there should be no risk of
[306] Fix | Delete
blocking in get_request().
[307] Fix | Delete
"""
[308] Fix | Delete
try:
[309] Fix | Delete
request, client_address = self.get_request()
[310] Fix | Delete
except OSError:
[311] Fix | Delete
return
[312] Fix | Delete
if self.verify_request(request, client_address):
[313] Fix | Delete
try:
[314] Fix | Delete
self.process_request(request, client_address)
[315] Fix | Delete
except Exception:
[316] Fix | Delete
self.handle_error(request, client_address)
[317] Fix | Delete
self.shutdown_request(request)
[318] Fix | Delete
except:
[319] Fix | Delete
self.shutdown_request(request)
[320] Fix | Delete
raise
[321] Fix | Delete
else:
[322] Fix | Delete
self.shutdown_request(request)
[323] Fix | Delete
[324] Fix | Delete
def handle_timeout(self):
[325] Fix | Delete
"""Called if no new request arrives within self.timeout.
[326] Fix | Delete
[327] Fix | Delete
Overridden by ForkingMixIn.
[328] Fix | Delete
"""
[329] Fix | Delete
pass
[330] Fix | Delete
[331] Fix | Delete
def verify_request(self, request, client_address):
[332] Fix | Delete
"""Verify the request. May be overridden.
[333] Fix | Delete
[334] Fix | Delete
Return True if we should proceed with this request.
[335] Fix | Delete
[336] Fix | Delete
"""
[337] Fix | Delete
return True
[338] Fix | Delete
[339] Fix | Delete
def process_request(self, request, client_address):
[340] Fix | Delete
"""Call finish_request.
[341] Fix | Delete
[342] Fix | Delete
Overridden by ForkingMixIn and ThreadingMixIn.
[343] Fix | Delete
[344] Fix | Delete
"""
[345] Fix | Delete
self.finish_request(request, client_address)
[346] Fix | Delete
self.shutdown_request(request)
[347] Fix | Delete
[348] Fix | Delete
def server_close(self):
[349] Fix | Delete
"""Called to clean-up the server.
[350] Fix | Delete
[351] Fix | Delete
May be overridden.
[352] Fix | Delete
[353] Fix | Delete
"""
[354] Fix | Delete
pass
[355] Fix | Delete
[356] Fix | Delete
def finish_request(self, request, client_address):
[357] Fix | Delete
"""Finish one request by instantiating RequestHandlerClass."""
[358] Fix | Delete
self.RequestHandlerClass(request, client_address, self)
[359] Fix | Delete
[360] Fix | Delete
def shutdown_request(self, request):
[361] Fix | Delete
"""Called to shutdown and close an individual request."""
[362] Fix | Delete
self.close_request(request)
[363] Fix | Delete
[364] Fix | Delete
def close_request(self, request):
[365] Fix | Delete
"""Called to clean up an individual request."""
[366] Fix | Delete
pass
[367] Fix | Delete
[368] Fix | Delete
def handle_error(self, request, client_address):
[369] Fix | Delete
"""Handle an error gracefully. May be overridden.
[370] Fix | Delete
[371] Fix | Delete
The default is to print a traceback and continue.
[372] Fix | Delete
[373] Fix | Delete
"""
[374] Fix | Delete
print('-'*40, file=sys.stderr)
[375] Fix | Delete
print('Exception happened during processing of request from',
[376] Fix | Delete
client_address, file=sys.stderr)
[377] Fix | Delete
import traceback
[378] Fix | Delete
traceback.print_exc()
[379] Fix | Delete
print('-'*40, file=sys.stderr)
[380] Fix | Delete
[381] Fix | Delete
def __enter__(self):
[382] Fix | Delete
return self
[383] Fix | Delete
[384] Fix | Delete
def __exit__(self, *args):
[385] Fix | Delete
self.server_close()
[386] Fix | Delete
[387] Fix | Delete
[388] Fix | Delete
class TCPServer(BaseServer):
[389] Fix | Delete
[390] Fix | Delete
"""Base class for various socket-based server classes.
[391] Fix | Delete
[392] Fix | Delete
Defaults to synchronous IP stream (i.e., TCP).
[393] Fix | Delete
[394] Fix | Delete
Methods for the caller:
[395] Fix | Delete
[396] Fix | Delete
- __init__(server_address, RequestHandlerClass, bind_and_activate=True)
[397] Fix | Delete
- serve_forever(poll_interval=0.5)
[398] Fix | Delete
- shutdown()
[399] Fix | Delete
- handle_request() # if you don't use serve_forever()
[400] Fix | Delete
- fileno() -> int # for selector
[401] Fix | Delete
[402] Fix | Delete
Methods that may be overridden:
[403] Fix | Delete
[404] Fix | Delete
- server_bind()
[405] Fix | Delete
- server_activate()
[406] Fix | Delete
- get_request() -> request, client_address
[407] Fix | Delete
- handle_timeout()
[408] Fix | Delete
- verify_request(request, client_address)
[409] Fix | Delete
- process_request(request, client_address)
[410] Fix | Delete
- shutdown_request(request)
[411] Fix | Delete
- close_request(request)
[412] Fix | Delete
- handle_error()
[413] Fix | Delete
[414] Fix | Delete
Methods for derived classes:
[415] Fix | Delete
[416] Fix | Delete
- finish_request(request, client_address)
[417] Fix | Delete
[418] Fix | Delete
Class variables that may be overridden by derived classes or
[419] Fix | Delete
instances:
[420] Fix | Delete
[421] Fix | Delete
- timeout
[422] Fix | Delete
- address_family
[423] Fix | Delete
- socket_type
[424] Fix | Delete
- request_queue_size (only for stream sockets)
[425] Fix | Delete
- allow_reuse_address
[426] Fix | Delete
[427] Fix | Delete
Instance variables:
[428] Fix | Delete
[429] Fix | Delete
- server_address
[430] Fix | Delete
- RequestHandlerClass
[431] Fix | Delete
- socket
[432] Fix | Delete
[433] Fix | Delete
"""
[434] Fix | Delete
[435] Fix | Delete
address_family = socket.AF_INET
[436] Fix | Delete
[437] Fix | Delete
socket_type = socket.SOCK_STREAM
[438] Fix | Delete
[439] Fix | Delete
request_queue_size = 5
[440] Fix | Delete
[441] Fix | Delete
allow_reuse_address = False
[442] Fix | Delete
[443] Fix | Delete
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
[444] Fix | Delete
"""Constructor. May be extended, do not override."""
[445] Fix | Delete
BaseServer.__init__(self, server_address, RequestHandlerClass)
[446] Fix | Delete
self.socket = socket.socket(self.address_family,
[447] Fix | Delete
self.socket_type)
[448] Fix | Delete
if bind_and_activate:
[449] Fix | Delete
try:
[450] Fix | Delete
self.server_bind()
[451] Fix | Delete
self.server_activate()
[452] Fix | Delete
except:
[453] Fix | Delete
self.server_close()
[454] Fix | Delete
raise
[455] Fix | Delete
[456] Fix | Delete
def server_bind(self):
[457] Fix | Delete
"""Called by constructor to bind the socket.
[458] Fix | Delete
[459] Fix | Delete
May be overridden.
[460] Fix | Delete
[461] Fix | Delete
"""
[462] Fix | Delete
if self.allow_reuse_address:
[463] Fix | Delete
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[464] Fix | Delete
self.socket.bind(self.server_address)
[465] Fix | Delete
self.server_address = self.socket.getsockname()
[466] Fix | Delete
[467] Fix | Delete
def server_activate(self):
[468] Fix | Delete
"""Called by constructor to activate the server.
[469] Fix | Delete
[470] Fix | Delete
May be overridden.
[471] Fix | Delete
[472] Fix | Delete
"""
[473] Fix | Delete
self.socket.listen(self.request_queue_size)
[474] Fix | Delete
[475] Fix | Delete
def server_close(self):
[476] Fix | Delete
"""Called to clean-up the server.
[477] Fix | Delete
[478] Fix | Delete
May be overridden.
[479] Fix | Delete
[480] Fix | Delete
"""
[481] Fix | Delete
self.socket.close()
[482] Fix | Delete
[483] Fix | Delete
def fileno(self):
[484] Fix | Delete
"""Return socket file number.
[485] Fix | Delete
[486] Fix | Delete
Interface required by selector.
[487] Fix | Delete
[488] Fix | Delete
"""
[489] Fix | Delete
return self.socket.fileno()
[490] Fix | Delete
[491] Fix | Delete
def get_request(self):
[492] Fix | Delete
"""Get the request and client address from the socket.
[493] Fix | Delete
[494] Fix | Delete
May be overridden.
[495] Fix | Delete
[496] Fix | Delete
"""
[497] Fix | Delete
return self.socket.accept()
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function