设为首页 加入收藏

TOP

Python select(三)
2017-12-18 12:37:26 】 浏览:338
Tags:Python select
message_queues[s] for s in writable: try: next_msg = message_queues[s].get_nowait() except queue.Empty: # 没有数据了,该连接对象队列为空,停止检测 print('output queue for [%s] is empty' % s.getpeername()[0]) outputs.remove(s) else: print('send %s to %s' % (next_msg, s.getpeername()[0])) s.send(next_msg) for s in exceptional: print('handling exceptional condition for', s.getpeername()[0]) # 从inputs中删除 inputs.remove(s) if s in outputs: outputs.remove(s) s.close() # 删除队列 del message_queues[s]

  client

# -*- coding: UTF-8 -*-
import socket

HOST = 'localhost'  # The remote host
PORT = 9999  # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
while True:
    msg = bytes(input(">>:"), encoding="utf8")
    s.sendall(msg)
    data = s.recv(1024)
    # print(data)

    print('Received', repr(data))

  

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇python3 三级菜单-基础版 下一篇数据开源 - Boss直聘岗位和招聘信..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目