I CAN connect socket to any localhost port but I shouldn't be able to

qvx qvx3000 at gmail.com
Tue Jul 29 13:56:08 EDT 2008


Hi,

I don't have server listening on port 8084 but I can open socket to it
(and to many other ports, tested for all<8000)

import socket
def test(port):
    af, socktype, proto, canonname, sa =
socket.getaddrinfo('localhost', port,
        socket.AF_INET, socket.SOCK_STREAM)[0]
    s = socket.socket(af, socktype, proto)
    s.settimeout(1.0)
    s.connect(('localhost', port))
    s.close()

# This doesn't throw socket.error, it happily finishes
for x in range(1, 8000):
    test(x)


Thanks,
Tvrtko



More information about the Python-list mailing list