[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
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条)