セレクトの使い方に困っています。データを受信するためにまだそこにいるクライアントを知りたいだけです。私のコードがあります:
import socket, select
server = socket.socket()
server.bind(('localhost',80))
server.listen(1)
answer = "HTTP/1.1 200 OK\r\n"
answer+= "Content-type: text/plain\r\n"
answer+= "Connection: close\r\n"
body = "test msg"
answer+= "Content-length: %d\r\n\r\n" % len(body)
answer+= body
clients = []
while True:
nextclient,addr = server.accept()
clients.append(nextclient)
clients = select.select([],clients,[],0.0)[1]
for client in clients:
client.send(answer)
すべてのソケットが開かれるたびに select send me が送信され、相手側で接続が閉じられた場合でも、Errno1053 が発生します: 確立された接続がホスト マシンのソフトウェアによって中止されました。
よろしくお願いします。