Python VNC ip扫描程序错误

时间:2016-05-09 19:32:27

标签: python vnc

您好我很困惑,为什么我收到此错误

代码:

#!/usr/bin/python -w
import random
import socket
from random import randint

username = 'admin'
password = 'admin'

print 'Format:'
print '101.109'
range = raw_input("Range: ")

def main():
    return '%s.%i.%i' % (range, rand(), rand())

def rand():
    return randint (1,254)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

while True:
    print 'Scanning %s:%s - %s' % (username, password, main())
    port = (5900)
    s.connect((main(), port))

错误代码:

Format:
101.109
Range: 101.109
Scanning admin:admin - 101.109.154.9
Traceback (most recent call last):
  File "C:\Users\Aries\Desktop\crap\Reflect.py", line 24, in <module>
    s.connect((main(), port))
  File "C:\Python27\lib\socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

所以我的朋友想让我制作一个VNC IP扫描仪,以便我正在做什么,我试图连接到它找到真正的VNC ips但是当它这样做时我得到一个错误,如你在顶部看到的

编辑:更多信息

我需要知道如果连接不起来我怎么能不让我错误

1 个答案:

答案 0 :(得分:0)

connect包裹在try/except块中:

Host = main()
try:
    s.connect((Host, port))
    print "Port {} is open on host {}".format(port, Host)
except:
    print "Connection failed" # or just pass