python socket Select模型
2014-04-16 00:46
309 查看
import socket
import sys
import socket
import select
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('192.168.1.103',21152))
print("Connected Ok!")
while 1:
infds,outfds,errfds = select.select([s],[],[s],0.05)
if len(infds):
data = s.recv(4096)
if not len(data):
print("\r Remote end closed connection;exiting.")
break;
sys.stdout.write("\rReceived:"+data)
sys.stdout.flush()
if len(errfds):
print("\rProblem occurred;exiting.")
sys.exit(0)
编译通过 ,接受收据正常
Connected Ok!
Wed Apr 16 00:22:24 2014
Wed Apr 16 00:22:29 2014
Wed Apr 16 00:22:39 2014
Wed Apr 16 00:22:44 2014
Wed Apr 16 00:22:49 2014
Wed Apr 16 00:22:54 2014
Wed Apr 16 00:22:59 2014
Wed Apr 16 00:23:04 2014
import sys
import socket
import select
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('192.168.1.103',21152))
print("Connected Ok!")
while 1:
infds,outfds,errfds = select.select([s],[],[s],0.05)
if len(infds):
data = s.recv(4096)
if not len(data):
print("\r Remote end closed connection;exiting.")
break;
sys.stdout.write("\rReceived:"+data)
sys.stdout.flush()
if len(errfds):
print("\rProblem occurred;exiting.")
sys.exit(0)
编译通过 ,接受收据正常
Connected Ok!
Wed Apr 16 00:22:24 2014
Wed Apr 16 00:22:29 2014
Wed Apr 16 00:22:39 2014
Wed Apr 16 00:22:44 2014
Wed Apr 16 00:22:49 2014
Wed Apr 16 00:22:54 2014
Wed Apr 16 00:22:59 2014
Wed Apr 16 00:23:04 2014
相关文章推荐
- [Python]Socket高级 -- select I/O复用模型(一)
- 状态集合[Python]Socket高级 -- select I/O复用模型(二)
- python实现select和epoll模型socket网络编程
- 参数文件描述符[Python]Socket高级 -- select I/O复用模型(一)
- python实现select和epoll模型socket网络编程 推荐
- [Python]Socket高级 -- select I/O复用模型(二)
- python select實現非阻塞socket
- socket编程的select模型
- socket编程的select模型
- SOCKET学习第三阶段(SELECT模型)
- python socket的select,poll,epoll
- python select模块.select实现非阻塞socket,Popen等(特别在 Unix 下,它还可以用于管道)
- (一)Socket I/O模型之选择(select)
- 【python网络编程】利用select实现socket全双工异步通信
- 基于Select模型的Socket服务器
- socket编程的select模型
- 在python中编写socket服务端模块(一):使用select
- UNIX环境高级编程学习之第十六章网络IPC:套接字 - 非阻塞的Socket通信Select模型(多路复用), 实用Socket通信模板。
- Unix Socket编程--I/O复用之select模型
- (二)Socket I/O模型之异步选择(WSAAsyncSelect)