私のサーバーは私の選択機能で正常に動作します:
readable, writable, exceptional = select.select(inputs, outputs, timeout)
書き込み可能な loop のコードは次のとおりです。
for s in writable:
try:
next_msg = message_queues[s].get_nowait()
except Queue.Empty:
# No messages waiting so stop checking for writability.
print >>sys.stderr, 'output queue for', s.getpeername(), 'is empty'
outputs.remove(s)
else:
print >>sys.stderr, 'sending "%s" to %s' % (next_msg, s.getpeername())
s.send(next_msg)
s はソケット オブジェクトです。ここで、コードは何かを送信しているクライアントにのみ送信されます。next_msg を相互に書き込み可能なソケットにマルチキャストしたいだけなので、試してみました:
for s in writable:
try:
next_msg = message_queues[s].get_nowait()
except Queue.Empty:
# No messages waiting so stop checking for writability.
print >>sys.stderr, 'output queue for', s.getpeername(), 'is empty'
outputs.remove(s)
else:
for multicast in writable:
print >>sys.stderr, 'sending "%s" to %s' % (next_msg, multicast.getpeername())
multicast.send(next_msg)
しかし、それは機能しません。常に送信者にのみ送信されます。