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

Q

qvx

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
 
G

Gabriel Genellina

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)

Your example fails -as expected- on my PC running Python 2.5.2 + Windows
XP SP2. It may be something specific to your setup or your platform.

py> test(8084)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in test
File "<string>", line 1, in connect
socket.error: (10061, 'Connection refused')
 
Q

qvx

Your example fails -as expected- on my PC running Python 2.5.2 + Windows  
XP SP2. It may be something specific to your setup or your platform.

py> test(8084)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 5, in test
   File "<string>", line 1, in connect
socket.error: (10061, 'Connection refused')

Thanks for confirmation. There is a similar function in CherryPy
server which won't start anymore but it used to. I am currently
examining Windows and any recently installed software.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top