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

Discussion in 'Python' started by qvx, Jul 29, 2008.

  1. qvx

    qvx Guest

    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
     
    qvx, Jul 29, 2008
    #1
    1. Advertising

  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 <> escribi�:

    > 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')
    --
    Gabriel Genellina
     
    Gabriel Genellina, Jul 30, 2008
    #2
    1. Advertising

  3. qvx

    qvx Guest

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

    On Jul 30, 4:48 am, "Gabriel Genellina" <>
    wrote:
    > En Tue, 29 Jul 2008 14:56:08 -0300, qvx <> escribi :
    >
    > > 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')
    > --
    > 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
     
    qvx, Jul 30, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    4
    Views:
    573
    Hasani Blackwell
    Feb 8, 2005
  2. Andres Monroy-Hernandez
    Replies:
    1
    Views:
    174
    Tony Curtis
    Jun 28, 2003
  3. Replies:
    6
    Views:
    141
    Uri Guttman
    Aug 18, 2006
  4. Wolfram Humann

    Can't connect to 'localhost' in IO::Socket

    Wolfram Humann, Feb 20, 2012, in forum: Perl Misc
    Replies:
    15
    Views:
    1,015
    Mart van de Wege
    Feb 23, 2012
  5. Heinrich Wolf
    Replies:
    3
    Views:
    405
    Heinrich Wolf
    Apr 29, 2012
Loading...

Share This Page