Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > I CAN connect socket to any localhost port but I shouldn't be able to

Reply
Thread Tools

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

 
 
qvx
Guest
Posts: n/a
 
      07-29-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
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      07-30-2008
En Tue, 29 Jul 2008 14:56:08 -0300, qvx <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
 
qvx
Guest
Posts: n/a
 
      07-30-2008
On Jul 30, 4:48*am, "Gabriel Genellina" <(E-Mail Removed)>
wrote:
> En Tue, 29 Jul 2008 14:56:08 -0300, qvx <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to 'localhost' in IO::Socket Wolfram Humann Perl Misc 15 02-23-2012 07:05 AM
Connect to 802.11b but not 802.11g... but used to be able to...? jbraly@gmail.com Wireless Networking 1 03-13-2006 11:05 PM
Able to Connect to wireless router, but can't see internet =?Utf-8?B?am9lQg==?= Wireless Networking 7 03-13-2006 06:26 AM
Can I Reset the Root from localhost/myproject/ to localhost/ Alex ASP .Net 4 02-08-2005 01:45 PM
Mail::Sendmail cannot connect to localhost but the mail command can Andres Monroy-Hernandez Perl Misc 1 06-27-2003 11:58 PM



Advertisments