python囧写囧一囧个囧s囧4囧服囧务囧端
发布网友
发布时间:2022-04-22 04:32
我来回答
共2个回答
热心网友
时间:2022-04-18 23:51
import asyncore
import socket
class EchoHandler(asyncore.dispatcher_with_send):
def handle_read(self):
data = self.recv(8192)
if data:
self.send(data)
class EchoServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((host, port))
self.listen(5)
def handle_accept(self):
pair = self.accept()
if pair is not None:
sock, addr = pair
print 'Incoming connection from %s' % repr(addr)
handler = EchoHandler(sock)
server = EchoServer('localhost', 8080)#不行可以试下换上你的ip
asyncore.loop()追问不行啊 打不开网页啊,浏览器指定本机8080端口 数据不通
热心网友
时间:2022-04-19 01:09
import dd
sockst (127.1, 8080)