码迷,mamicode.com
首页 > 编程语言 > 详细

python-非阻塞IO

时间:2018-06-16 10:30:48      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:进程   als   python   bre   block   nec   set   dal   close   

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

标签:进程   als   python   bre   block   nec   set   dal   close   

原文地址:https://www.cnblogs.com/benchdog/p/9189501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!