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