阅读背景:

使用Python测试端口是否正在使用的快速方法

来源:互联网 

I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason.I have a python server that listens on a couple




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: