Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../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
save 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 errno
[128] Fix | Delete
import sys
[129] Fix | Delete
try:
[130] Fix | Delete
import threading
[131] Fix | Delete
except ImportError:
[132] Fix | Delete
import dummy_threading as threading
[133] Fix | Delete
from io import BufferedIOBase
[134] Fix | Delete
from time import monotonic as time
[135] Fix | Delete
[136] Fix | Delete
__all__ = ["BaseServer", "TCPServer", "UDPServer",
[137] Fix | Delete
"ThreadingUDPServer", "ThreadingTCPServer",
[138] Fix | Delete
"BaseRequestHandler", "StreamRequestHandler",
[139] Fix | Delete
"DatagramRequestHandler", "ThreadingMixIn"]
[140] Fix | Delete
if hasattr(os, "fork"):
[141] Fix | Delete
__all__.extend(["ForkingUDPServer","ForkingTCPServer", "ForkingMixIn"])
[142] Fix | Delete
if hasattr(socket, "AF_UNIX"):
[143] Fix | Delete
__all__.extend(["UnixStreamServer","UnixDatagramServer",
[144] Fix | Delete
"ThreadingUnixStreamServer",
[145] Fix | Delete
"ThreadingUnixDatagramServer"])
[146] Fix | Delete
[147] Fix | Delete
# poll/select have the advantage of not requiring any extra file descriptor,
[148] Fix | Delete
# contrarily to epoll/kqueue (also, they require a single syscall).
[149] Fix | Delete
if hasattr(selectors, 'PollSelector'):
[150] Fix | Delete
_ServerSelector = selectors.PollSelector
[151] Fix | Delete
else:
[152] Fix | Delete
_ServerSelector = selectors.SelectSelector
[153] Fix | Delete
[154] Fix | Delete
[155] Fix | Delete
class BaseServer:
[156] Fix | Delete
[157] Fix | Delete
"""Base class for server classes.
[158] Fix | Delete
[159] Fix | Delete
Methods for the caller:
[160] Fix | Delete
[161] Fix | Delete
- __init__(server_address, RequestHandlerClass)
[162] Fix | Delete
- serve_forever(poll_interval=0.5)
[163] Fix | Delete
- shutdown()
[164] Fix | Delete
- handle_request() # if you do not use serve_forever()
[165] Fix | Delete
- fileno() -> int # for selector
[166] Fix | Delete
[167] Fix | Delete
Methods that may be overridden:
[168] Fix | Delete
[169] Fix | Delete
- server_bind()
[170] Fix | Delete
- server_activate()
[171] Fix | Delete
- get_request() -> request, client_address
[172] Fix | Delete
- handle_timeout()
[173] Fix | Delete
- verify_request(request, client_address)
[174] Fix | Delete
- server_close()
[175] Fix | Delete
- process_request(request, client_address)
[176] Fix | Delete
- shutdown_request(request)
[177] Fix | Delete
- close_request(request)
[178] Fix | Delete
- service_actions()
[179] Fix | Delete
- handle_error()
[180] Fix | Delete
[181] Fix | Delete
Methods for derived classes:
[182] Fix | Delete
[183] Fix | Delete
- finish_request(request, client_address)
[184] Fix | Delete
[185] Fix | Delete
Class variables that may be overridden by derived classes or
[186] Fix | Delete
instances:
[187] Fix | Delete
[188] Fix | Delete
- timeout
[189] Fix | Delete
- address_family
[190] Fix | Delete
- socket_type
[191] Fix | Delete
- allow_reuse_address
[192] Fix | Delete
[193] Fix | Delete
Instance variables:
[194] Fix | Delete
[195] Fix | Delete
- RequestHandlerClass
[196] Fix | Delete
- socket
[197] Fix | Delete
[198] Fix | Delete
"""
[199] Fix | Delete
[200] Fix | Delete
timeout = None
[201] Fix | Delete
[202] Fix | Delete
def __init__(self, server_address, RequestHandlerClass):
[203] Fix | Delete
"""Constructor. May be extended, do not override."""
[204] Fix | Delete
self.server_address = server_address
[205] Fix | Delete
self.RequestHandlerClass = RequestHandlerClass
[206] Fix | Delete
self.__is_shut_down = threading.Event()
[207] Fix | Delete
self.__shutdown_request = False
[208] Fix | Delete
[209] Fix | Delete
def server_activate(self):
[210] Fix | Delete
"""Called by constructor to activate the server.
[211] Fix | Delete
[212] Fix | Delete
May be overridden.
[213] Fix | Delete
[214] Fix | Delete
"""
[215] Fix | Delete
pass
[216] Fix | Delete
[217] Fix | Delete
def serve_forever(self, poll_interval=0.5):
[218] Fix | Delete
"""Handle one request at a time until shutdown.
[219] Fix | Delete
[220] Fix | Delete
Polls for shutdown every poll_interval seconds. Ignores
[221] Fix | Delete
self.timeout. If you need to do periodic tasks, do them in
[222] Fix | Delete
another thread.
[223] Fix | Delete
"""
[224] Fix | Delete
self.__is_shut_down.clear()
[225] Fix | Delete
try:
[226] Fix | Delete
# XXX: Consider using another file descriptor or connecting to the
[227] Fix | Delete
# socket to wake this up instead of polling. Polling reduces our
[228] Fix | Delete
# responsiveness to a shutdown request and wastes cpu at all other
[229] Fix | Delete
# times.
[230] Fix | Delete
with _ServerSelector() as selector:
[231] Fix | Delete
selector.register(self, selectors.EVENT_READ)
[232] Fix | Delete
[233] Fix | Delete
while not self.__shutdown_request:
[234] Fix | Delete
ready = selector.select(poll_interval)
[235] Fix | Delete
# bpo-35017: shutdown() called during select(), exit immediately.
[236] Fix | Delete
if self.__shutdown_request:
[237] Fix | Delete
break
[238] Fix | Delete
if ready:
[239] Fix | Delete
self._handle_request_noblock()
[240] Fix | Delete
[241] Fix | Delete
self.service_actions()
[242] Fix | Delete
finally:
[243] Fix | Delete
self.__shutdown_request = False
[244] Fix | Delete
self.__is_shut_down.set()
[245] Fix | Delete
[246] Fix | Delete
def shutdown(self):
[247] Fix | Delete
"""Stops the serve_forever loop.
[248] Fix | Delete
[249] Fix | Delete
Blocks until the loop has finished. This must be called while
[250] Fix | Delete
serve_forever() is running in another thread, or it will
[251] Fix | Delete
deadlock.
[252] Fix | Delete
"""
[253] Fix | Delete
self.__shutdown_request = True
[254] Fix | Delete
self.__is_shut_down.wait()
[255] Fix | Delete
[256] Fix | Delete
def service_actions(self):
[257] Fix | Delete
"""Called by the serve_forever() loop.
[258] Fix | Delete
[259] Fix | Delete
May be overridden by a subclass / Mixin to implement any code that
[260] Fix | Delete
needs to be run during the loop.
[261] Fix | Delete
"""
[262] Fix | Delete
pass
[263] Fix | Delete
[264] Fix | Delete
# The distinction between handling, getting, processing and finishing a
[265] Fix | Delete
# request is fairly arbitrary. Remember:
[266] Fix | Delete
#
[267] Fix | Delete
# - handle_request() is the top-level call. It calls selector.select(),
[268] Fix | Delete
# get_request(), verify_request() and process_request()
[269] Fix | Delete
# - get_request() is different for stream or datagram sockets
[270] Fix | Delete
# - process_request() is the place that may fork a new process or create a
[271] Fix | Delete
# new thread to finish the request
[272] Fix | Delete
# - finish_request() instantiates the request handler class; this
[273] Fix | Delete
# constructor will handle the request all by itself
[274] Fix | Delete
[275] Fix | Delete
def handle_request(self):
[276] Fix | Delete
"""Handle one request, possibly blocking.
[277] Fix | Delete
[278] Fix | Delete
Respects self.timeout.
[279] Fix | Delete
"""
[280] Fix | Delete
# Support people who used socket.settimeout() to escape
[281] Fix | Delete
# handle_request before self.timeout was available.
[282] Fix | Delete
timeout = self.socket.gettimeout()
[283] Fix | Delete
if timeout is None:
[284] Fix | Delete
timeout = self.timeout
[285] Fix | Delete
elif self.timeout is not None:
[286] Fix | Delete
timeout = min(timeout, self.timeout)
[287] Fix | Delete
if timeout is not None:
[288] Fix | Delete
deadline = time() + timeout
[289] Fix | Delete
[290] Fix | Delete
# Wait until a request arrives or the timeout expires - the loop is
[291] Fix | Delete
# necessary to accommodate early wakeups due to EINTR.
[292] Fix | Delete
with _ServerSelector() as selector:
[293] Fix | Delete
selector.register(self, selectors.EVENT_READ)
[294] Fix | Delete
[295] Fix | Delete
while True:
[296] Fix | Delete
ready = selector.select(timeout)
[297] Fix | Delete
if ready:
[298] Fix | Delete
return self._handle_request_noblock()
[299] Fix | Delete
else:
[300] Fix | Delete
if timeout is not None:
[301] Fix | Delete
timeout = deadline - time()
[302] Fix | Delete
if timeout < 0:
[303] Fix | Delete
return self.handle_timeout()
[304] Fix | Delete
[305] Fix | Delete
def _handle_request_noblock(self):
[306] Fix | Delete
"""Handle one request, without blocking.
[307] Fix | Delete
[308] Fix | Delete
I assume that selector.select() has returned that the socket is
[309] Fix | Delete
readable before this function was called, so there should be no risk of
[310] Fix | Delete
blocking in get_request().
[311] Fix | Delete
"""
[312] Fix | Delete
try:
[313] Fix | Delete
request, client_address = self.get_request()
[314] Fix | Delete
except OSError:
[315] Fix | Delete
return
[316] Fix | Delete
if self.verify_request(request, client_address):
[317] Fix | Delete
try:
[318] Fix | Delete
self.process_request(request, client_address)
[319] Fix | Delete
except Exception:
[320] Fix | Delete
self.handle_error(request, client_address)
[321] Fix | Delete
self.shutdown_request(request)
[322] Fix | Delete
except:
[323] Fix | Delete
self.shutdown_request(request)
[324] Fix | Delete
raise
[325] Fix | Delete
else:
[326] Fix | Delete
self.shutdown_request(request)
[327] Fix | Delete
[328] Fix | Delete
def handle_timeout(self):
[329] Fix | Delete
"""Called if no new request arrives within self.timeout.
[330] Fix | Delete
[331] Fix | Delete
Overridden by ForkingMixIn.
[332] Fix | Delete
"""
[333] Fix | Delete
pass
[334] Fix | Delete
[335] Fix | Delete
def verify_request(self, request, client_address):
[336] Fix | Delete
"""Verify the request. May be overridden.
[337] Fix | Delete
[338] Fix | Delete
Return True if we should proceed with this request.
[339] Fix | Delete
[340] Fix | Delete
"""
[341] Fix | Delete
return True
[342] Fix | Delete
[343] Fix | Delete
def process_request(self, request, client_address):
[344] Fix | Delete
"""Call finish_request.
[345] Fix | Delete
[346] Fix | Delete
Overridden by ForkingMixIn and ThreadingMixIn.
[347] Fix | Delete
[348] Fix | Delete
"""
[349] Fix | Delete
self.finish_request(request, client_address)
[350] Fix | Delete
self.shutdown_request(request)
[351] Fix | Delete
[352] Fix | Delete
def server_close(self):
[353] Fix | Delete
"""Called to clean-up the server.
[354] Fix | Delete
[355] Fix | Delete
May be overridden.
[356] Fix | Delete
[357] Fix | Delete
"""
[358] Fix | Delete
pass
[359] Fix | Delete
[360] Fix | Delete
def finish_request(self, request, client_address):
[361] Fix | Delete
"""Finish one request by instantiating RequestHandlerClass."""
[362] Fix | Delete
self.RequestHandlerClass(request, client_address, self)
[363] Fix | Delete
[364] Fix | Delete
def shutdown_request(self, request):
[365] Fix | Delete
"""Called to shutdown and close an individual request."""
[366] Fix | Delete
self.close_request(request)
[367] Fix | Delete
[368] Fix | Delete
def close_request(self, request):
[369] Fix | Delete
"""Called to clean up an individual request."""
[370] Fix | Delete
pass
[371] Fix | Delete
[372] Fix | Delete
def handle_error(self, request, client_address):
[373] Fix | Delete
"""Handle an error gracefully. May be overridden.
[374] Fix | Delete
[375] Fix | Delete
The default is to print a traceback and continue.
[376] Fix | Delete
[377] Fix | Delete
"""
[378] Fix | Delete
print('-'*40, file=sys.stderr)
[379] Fix | Delete
print('Exception happened during processing of request from',
[380] Fix | Delete
client_address, file=sys.stderr)
[381] Fix | Delete
import traceback
[382] Fix | Delete
traceback.print_exc()
[383] Fix | Delete
print('-'*40, file=sys.stderr)
[384] Fix | Delete
[385] Fix | Delete
def __enter__(self):
[386] Fix | Delete
return self
[387] Fix | Delete
[388] Fix | Delete
def __exit__(self, *args):
[389] Fix | Delete
self.server_close()
[390] Fix | Delete
[391] Fix | Delete
[392] Fix | Delete
class TCPServer(BaseServer):
[393] Fix | Delete
[394] Fix | Delete
"""Base class for various socket-based server classes.
[395] Fix | Delete
[396] Fix | Delete
Defaults to synchronous IP stream (i.e., TCP).
[397] Fix | Delete
[398] Fix | Delete
Methods for the caller:
[399] Fix | Delete
[400] Fix | Delete
- __init__(server_address, RequestHandlerClass, bind_and_activate=True)
[401] Fix | Delete
- serve_forever(poll_interval=0.5)
[402] Fix | Delete
- shutdown()
[403] Fix | Delete
- handle_request() # if you don't use serve_forever()
[404] Fix | Delete
- fileno() -> int # for selector
[405] Fix | Delete
[406] Fix | Delete
Methods that may be overridden:
[407] Fix | Delete
[408] Fix | Delete
- server_bind()
[409] Fix | Delete
- server_activate()
[410] Fix | Delete
- get_request() -> request, client_address
[411] Fix | Delete
- handle_timeout()
[412] Fix | Delete
- verify_request(request, client_address)
[413] Fix | Delete
- process_request(request, client_address)
[414] Fix | Delete
- shutdown_request(request)
[415] Fix | Delete
- close_request(request)
[416] Fix | Delete
- handle_error()
[417] Fix | Delete
[418] Fix | Delete
Methods for derived classes:
[419] Fix | Delete
[420] Fix | Delete
- finish_request(request, client_address)
[421] Fix | Delete
[422] Fix | Delete
Class variables that may be overridden by derived classes or
[423] Fix | Delete
instances:
[424] Fix | Delete
[425] Fix | Delete
- timeout
[426] Fix | Delete
- address_family
[427] Fix | Delete
- socket_type
[428] Fix | Delete
- request_queue_size (only for stream sockets)
[429] Fix | Delete
- allow_reuse_address
[430] Fix | Delete
[431] Fix | Delete
Instance variables:
[432] Fix | Delete
[433] Fix | Delete
- server_address
[434] Fix | Delete
- RequestHandlerClass
[435] Fix | Delete
- socket
[436] Fix | Delete
[437] Fix | Delete
"""
[438] Fix | Delete
[439] Fix | Delete
address_family = socket.AF_INET
[440] Fix | Delete
[441] Fix | Delete
socket_type = socket.SOCK_STREAM
[442] Fix | Delete
[443] Fix | Delete
request_queue_size = 5
[444] Fix | Delete
[445] Fix | Delete
allow_reuse_address = False
[446] Fix | Delete
[447] Fix | Delete
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
[448] Fix | Delete
"""Constructor. May be extended, do not override."""
[449] Fix | Delete
BaseServer.__init__(self, server_address, RequestHandlerClass)
[450] Fix | Delete
self.socket = socket.socket(self.address_family,
[451] Fix | Delete
self.socket_type)
[452] Fix | Delete
if bind_and_activate:
[453] Fix | Delete
try:
[454] Fix | Delete
self.server_bind()
[455] Fix | Delete
self.server_activate()
[456] Fix | Delete
except:
[457] Fix | Delete
self.server_close()
[458] Fix | Delete
raise
[459] Fix | Delete
[460] Fix | Delete
def server_bind(self):
[461] Fix | Delete
"""Called by constructor to bind the socket.
[462] Fix | Delete
[463] Fix | Delete
May be overridden.
[464] Fix | Delete
[465] Fix | Delete
"""
[466] Fix | Delete
if self.allow_reuse_address:
[467] Fix | Delete
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[468] Fix | Delete
self.socket.bind(self.server_address)
[469] Fix | Delete
self.server_address = self.socket.getsockname()
[470] Fix | Delete
[471] Fix | Delete
def server_activate(self):
[472] Fix | Delete
"""Called by constructor to activate the server.
[473] Fix | Delete
[474] Fix | Delete
May be overridden.
[475] Fix | Delete
[476] Fix | Delete
"""
[477] Fix | Delete
self.socket.listen(self.request_queue_size)
[478] Fix | Delete
[479] Fix | Delete
def server_close(self):
[480] Fix | Delete
"""Called to clean-up the server.
[481] Fix | Delete
[482] Fix | Delete
May be overridden.
[483] Fix | Delete
[484] Fix | Delete
"""
[485] Fix | Delete
self.socket.close()
[486] Fix | Delete
[487] Fix | Delete
def fileno(self):
[488] Fix | Delete
"""Return socket file number.
[489] Fix | Delete
[490] Fix | Delete
Interface required by selector.
[491] Fix | Delete
[492] Fix | Delete
"""
[493] Fix | Delete
return self.socket.fileno()
[494] Fix | Delete
[495] Fix | Delete
def get_request(self):
[496] Fix | Delete
"""Get the request and client address from the socket.
[497] Fix | Delete
[498] Fix | Delete
May be overridden.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function