0
点赞
收藏
分享

微信扫一扫

socket connect超时

小贴贴纸happy 2022-04-23 阅读 65
tcp/ip

[root@xx~/sbin/socket]#cat test_connnect.py 

import SocketServer
import socket
import time
import sys
reload(sys)
print time.ctime()
sys.setdefaultencoding('utf-8')
import re
host='10.2.200.100'

port=300
bufsize=10240
addr=(host,port)
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(2)
s.connect((host,port))
[root@yyjk ~/sbin/socket]#time python test_connnect.py 
Sat Apr 23 09:32:50 2022
Traceback (most recent call last):
  File "test_connnect.py", line 17, in <module>
    s.connect((host,port))
  File "/usr/local/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.timeout: timed out

real 0m2.025s
user 0m0.020s
sys 0m0.002s

举报

相关推荐

0 条评论