所以,如果我有这样的服务器设置:
class Server():
def __init__(self, portNum):
self.sock = None
self.setup(portNum)
def setup(self, portNum):
# Create a UDP socket
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind the socket to the port
server_address = ('localhost', portNum)
print >> sys.stderr, 'starting up on %s port %s' % server_address
self.sock.bind(server_address)
def run(self):
while True:
print >>sys.stderr, '\nwaiting to receive message'
request, address = self.sock.recvfrom(4096)
print >>sys.stderr, 'received %s bytes from %s' % (len(request), address)
print >>sys.stderr, request
请求的数据类型是什么?如果我收到一个数据包,如果我说打印请求会得到什么[1]。那是一个完整的字节,还是字节串的一个字符?