Python的select使用關(guān)鍵點(diǎn)就select模塊的select函數(shù)
import select
readables,writeables,exceptions=select.select(readable_list,writeable_list,exception_list,time_out) #1
每執(zhí)行 1 這句話話,
情況一:
time_out為空的情況下蚕键,select會(huì)監(jiān)聽(tīng):
readable_list中的資源是否可讀灼狰,將讀就緒的資源返回到readables
writeable_list中的資源是否可寫(xiě)疾渣,將寫(xiě)就緒的資源返回到writeables
exception_list中的資源是否發(fā)生異常仪缸,將發(fā)生異常的資源放入exceptions
當(dāng)所有資源都沒(méi)有就緒的時(shí)候,select.select會(huì)阻塞當(dāng)前線程豆瘫,直到有某個(gè)資源就緒扼仲,然后返回
情況二:
time_out不為空的情況下,select會(huì)監(jiān)聽(tīng):
readable_list中的資源是否可讀途蒋,將讀就緒的資源返回到readables
writeable_list中的資源是否可寫(xiě)猛遍,將寫(xiě)就緒的資源返回到writeables
exception_list中的資源是否發(fā)生異常,將發(fā)生異常的資源放入exceptions
當(dāng)所有資源都沒(méi)有就緒的時(shí)候号坡,select.select會(huì)阻塞當(dāng)前線程懊烤,直到在time_out時(shí)間內(nèi)有某個(gè)資源就緒,然后返回宽堆;如果在timeout時(shí)間內(nèi)沒(méi)有資源就緒奸晴,那就返回三個(gè)空列表,也就是readables=writerables=exceptisons=[]
import select
import socket
import time
SERVER_HOST=('127.0.0.1',9999)
class Select_Server_01:
'''
使用select和可讀隊(duì)列日麸,可寫(xiě)隊(duì)列實(shí)現(xiàn)服務(wù)器
'''
def __init__(self):
#創(chuàng)建套接字
self.server_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#綁定端口
self.server_socket.bind(SERVER_HOST)
#設(shè)置為監(jiān)聽(tīng)套接字
self.server_socket.listen(5)
#可讀就緒資源列表
self.readable_list=[self.server_socket]
#可寫(xiě)就緒資源列表
self.writeable_list=[]
'''
存儲(chǔ)客戶端socket傳遞過(guò)來(lái)的參數(shù)
存儲(chǔ)結(jié)構(gòu)如下
鍵為:客戶端socket對(duì)象寄啼,值為socket對(duì)象傳入的值
'''
self.client_socket_args={}
def handle_request(self,request_args):
#根據(jù)傳入?yún)?shù)返回對(duì)應(yīng)的參數(shù)
return "{}時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):{}".format(time.time(),request_args)
'''
服務(wù)器運(yùn)行核心,通過(guò)while循環(huán)
'''
def run(self):
"""
主循環(huán)代箭,不斷循環(huán)處理可讀與可寫(xiě)隊(duì)列
:return:
"""
while True:
#select檢查并返回可讀與可寫(xiě)列表中那些就緒的socket
readables,writerables,exceptions=select.select(self.readable_list,self.writeable_list,[])
#處理每個(gè)可讀的socket
for readable_item in readables:
if readable_item==self.server_socket: #如果可讀就緒的是服務(wù)器socket墩划,則表示有新的客戶端接入
client_socket,client_socket_address=readable_item.accept()
#將新的客戶端socket存入可讀列表
self.readable_list.append(client_socket)
print('接收到新socket:{}'.format(client_socket))
else: #除了服務(wù)器socket就是客戶端socket可讀了,我們這里接收一下客戶端socket數(shù)據(jù)(這里是普通參數(shù))
recv_data=readable_item.recv(1024).decode('utf-8') #這是一個(gè)堵塞操作,客戶端最好不要一次發(fā)送太多的數(shù)據(jù)
if recv_data=='':
#如果客戶端發(fā)送空字符串嗡综,表示自己要關(guān)閉,所以我們要清除這個(gè)客戶端
#先關(guān)閉掉它
try:
readable_item.close()
except:
pass
#從客戶端請(qǐng)求參數(shù)列表中清除
if readable_item in self.client_socket_args:
del self.client_socket_args[readable_item]
#從可讀隊(duì)列中清除
if readable_item in self.readable_list:
self.readable_list.remove(readable_item)
#從可寫(xiě)隊(duì)列中清除
if readable_item in self.writeable_list:
self.writeable_list.remove(readable_item)
#從本輪的寫(xiě)就緒隊(duì)列中刪除(因?yàn)槲覀兘酉聛?lái)會(huì)處理可寫(xiě)socket)
if readable_item in writerables:
writerables.remove(readable_item)
print('清除socket:{}'.format(readable_item))
elif recv_data!='CLOSE_SERVER_ZHOUYUQING':
#將請(qǐng)求參數(shù)存入客戶端請(qǐng)求參數(shù)字典
self.client_socket_args[readable_item]=recv_data
#接下來(lái)我們要將客戶端socket放入可寫(xiě)隊(duì)列
if readable_item not in self.writeable_list:
self.writeable_list.append(readable_item)
print('處理socket:{}'.format(readable_item))
else: #客戶端發(fā)過(guò)來(lái)是關(guān)閉指令
self.close()
return
#處理每個(gè)可寫(xiě)的socket
for writeable_item in writerables:
#獲取這個(gè)socket對(duì)應(yīng)傳入?yún)?shù)
client_send_data=self.client_socket_args.get(writeable_item)
#向可寫(xiě)socket發(fā)送數(shù)據(jù)
print('當(dāng)前關(guān)于該socket:{} 的傳入?yún)?shù)是:{}'.format(writeable_item,client_send_data))
writeable_item.send(self.handle_request(client_send_data).encode('utf-8')) #阻塞操作
print('發(fā)送數(shù)據(jù)給:{}'.format(writeable_item))
#處理完這個(gè)可讀socket后從可讀隊(duì)列中刪除,知道它再次發(fā)送請(qǐng)求參數(shù)過(guò)來(lái)才會(huì)被添加到可讀隊(duì)列中
self.writeable_list.remove(writeable_item)
'''
關(guān)閉select_socket服務(wù)器
'''
def close(self):
#關(guān)閉所有存在的socket
for _socket in self.readable_list+self.writeable_list:
try:
_socket.close()
except:
pass
print('服務(wù)器執(zhí)行關(guān)閉所有操作')
class Client_Socket_01:
'''
測(cè)試客戶端socket
'''
def __init__(self):
self.client_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
def run(self,info,num):
self.client_socket.connect(SERVER_HOST)
for _ in range(num):
self.client_socket.send(info.encode('utf-8'))
print('\n\n {} 接收響應(yīng):{}\n\n'.format(info,self.client_socket.recv(1024).decode('utf-8')))
#發(fā)送關(guān)閉動(dòng)作(發(fā)送一個(gè)為空字符串)
self.client_socket.send(''.encode('utf-8'))
try:
self.client_socket.close()
except:
pass
import multiprocessing
def main_01():
#先啟動(dòng)服務(wù)器
server_socket=Select_Server_01()
multiprocessing.Process(target=server_socket.run).start()
#啟動(dòng)測(cè)試客戶端
client_socket_01=Client_Socket_01()
multiprocessing.Process(target=client_socket_01.run,args=('測(cè)試客戶端1',1)).start()
client_socket_02=Client_Socket_01()
multiprocessing.Process(target=client_socket_02.run,args=('測(cè)試客戶端2',3)).start()
client_socket_03=Client_Socket_01()
multiprocessing.Process(target=client_socket_03.run,args=('測(cè)試客戶端3',6)).start()
client_socket_04=Client_Socket_01()
multiprocessing.Process(target=client_socket_04.run,args=('測(cè)試客戶端4',9)).start()
#創(chuàng)建一個(gè)客戶端發(fā)送一個(gè)關(guān)閉指令給服務(wù)器
time.sleep(30) #這句話很重要乙帮,你不要一上來(lái)就把服務(wù)器關(guān)了
final_client_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
final_client_socket.connect(SERVER_HOST)
final_client_socket.send('CLOSE_SERVER_ZHOUYUQING'.encode('utf-8'))
try:
final_client_socket.close()
except:
pass
print('-------------------------->>>>>>>>>>>>>>>>執(zhí)行關(guān)閉服務(wù)器完畢')
"""
執(zhí)行:
main_01()
執(zhí)行結(jié)果:
接收到新socket:<socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34416)>
接收到新socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
處理socket:<socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34416)>
當(dāng)前關(guān)于該socket:<socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34416)> 的傳入?yún)?shù)是:測(cè)試客戶端1
發(fā)送數(shù)據(jù)給:<socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34416)>
測(cè)試客戶端1 接收響應(yīng):1548409232.0193949時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端1
處理socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
當(dāng)前關(guān)于該socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)> 的傳入?yún)?shù)是:測(cè)試客戶端2
發(fā)送數(shù)據(jù)給:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
測(cè)試客戶端2 接收響應(yīng):1548409232.0195627時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端2
處理socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
當(dāng)前關(guān)于該socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)> 的傳入?yún)?shù)是:測(cè)試客戶端2
發(fā)送數(shù)據(jù)給:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
測(cè)試客戶端2 接收響應(yīng):1548409232.0199127時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端2
處理socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
當(dāng)前關(guān)于該socket:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)> 的傳入?yún)?shù)是:測(cè)試客戶端2
發(fā)送數(shù)據(jù)給:<socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34418)>
接收到新socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
測(cè)試客戶端3 接收響應(yīng):1548409232.0201845時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
測(cè)試客戶端2 接收響應(yīng):1548409232.020043時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端2
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
測(cè)試客戶端3 接收響應(yīng):1548409232.020338時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
接收到新socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
測(cè)試客戶端4 接收響應(yīng):1548409232.0205855時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
測(cè)試客戶端3 接收響應(yīng):1548409232.020468時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
測(cè)試客戶端3 接收響應(yīng):1548409232.0207088時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
測(cè)試客戶端3 接收響應(yīng):1548409232.0208163時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
處理socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
當(dāng)前關(guān)于該socket:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)> 的傳入?yún)?shù)是:測(cè)試客戶端3
測(cè)試客戶端3 接收響應(yīng):1548409232.0208836時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端3
發(fā)送數(shù)據(jù)給:<socket.socket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34422)>
測(cè)試客戶端4 接收響應(yīng):1548409232.0207596時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
測(cè)試客戶端4 接收響應(yīng):1548409232.0210006時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
測(cè)試客戶端4 接收響應(yīng):1548409232.0211372時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
測(cè)試客戶端4 接收響應(yīng):1548409232.021273時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
測(cè)試客戶端4 接收響應(yīng):1548409232.0214124時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
測(cè)試客戶端4 接收響應(yīng):1548409232.021508時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
測(cè)試客戶端4 接收響應(yīng):1548409232.0216038時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
處理socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
當(dāng)前關(guān)于該socket:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)> 的傳入?yún)?shù)是:測(cè)試客戶端4
測(cè)試客戶端4 接收響應(yīng):1548409232.0217009時(shí)刻,經(jīng)過(guò)不負(fù)責(zé)任的socket處理過(guò)的數(shù)據(jù):測(cè)試客戶端4
發(fā)送數(shù)據(jù)給:<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34424)>
-------------------------->>>>>>>>>>>>>>>>執(zhí)行關(guān)閉服務(wù)器完畢
接收到新socket:<socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 9999), raddr=('127.0.0.1', 34438)>
服務(wù)器執(zhí)行關(guān)閉所有操作
"""