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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • qvx

    #1

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

    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.getaddri nfo('localhost' , port,
    socket.AF_INET, socket.SOCK_STR EAM)[0]
    s = socket.socket(a f, socktype, proto)
    s.settimeout(1. 0)
    s.connect(('loc alhost', port))
    s.close()

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


    Thanks,
    Tvrtko
  • Gabriel Genellina

    #2
    Re: I CAN connect socket to any localhost port but I shouldn't beable to

    En Tue, 29 Jul 2008 14:56:08 -0300, qvx <qvx3000@gmail. comescribi�:
    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.

    pytest(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')
    --
    Gabriel Genellina

    Comment

    • qvx

      #3
      Re: I CAN connect socket to any localhost port but I shouldn't beable to

      On Jul 30, 4:48 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
      wrote:
      En Tue, 29 Jul 2008 14:56:08 -0300, qvx <qvx3...@gmail. comescribi :
      >
      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.
      >
      pytest(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')
      --
      Gabriel Genellina
      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.
      --
      Tvrtko

      Comment

      Working...