を接続しているかどうかを確認する方法:パイソン - ソケットがまだ私は自明である次のコードを、持っている
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(host, port)
s.send("some data")
# don't close socket just yet...
# do some other stuff with the data (normal string operations)
if s.stillconnected() is true:
s.send("some more data")
if s.stillconnected() is false:
# recreate the socket and reconnect
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(host, port)
s.send("some more data")
s.close()
私は盲目的にソケットを再作成したくないどのように私はs.stillconnected()
を実装するのですが。
いい仕事+1ですが、ここにあなたの賞金に関するコメントがあります:https://superuser.com/questions/955266/prevent-windows-7-sleep-while-files-are-being-accessed-by-networkそしてletそれらのコメントの中に役立つものがあれば教えてください。 –