python-非阻塞IO
阿新 • • 發佈:2018-06-16
recv code conn waiting res import client wait bin
client端:
# import time # import socket # sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # # while True: # sk.connect((‘127.0.0.1‘,6667)) # print("hello") # sk.sendall(bytes("hello","utf8")) # time.sleep(2) # break
server端:
# import time # import socket # sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)# sk.bind((‘127.0.0.1‘,6667)) # sk.listen(5) # sk.setblocking(False) # print (‘waiting client connection .......‘) # while True: # try: # # connection,address = sk.accept() # 進程主動輪詢 # print("+++",address) # client_messge = connection.recv(1024) # print(str(client_messge,‘utf8‘)) # connection.close() #except Exception as e: # print (e) # time.sleep(4)
python-非阻塞IO