Listening socket not seen outside of localhost

Discussion in 'Python' started by Christian von Essen, Jun 21, 2004.

  1. Hi,

    As I don't know if my problem is python, platform or non-specific, I try
    to post my question here, as you may have made similar experiences.

    I try to write a simple chatserver, using the socket module. Everything
    works fine, as long as I'm trying to connect to the server from the host,
    the server is running. If I try to access the server from another computer
    in my local network, the connection is refused.

    No firewall is running and other services (like ssh or httpd) can be
    connected to.
    I'm running Python 2.3.4 on a AMD Athlon using Fedora Core 2.

    I initialize the sockets the following way:
    self._addr = socket.gethostname()
    self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
    True)
    self.socket.bind((self._addr, self._port))
    self.socket.listen(self._backlog)

    Then I'm accepting clients in an endless loop.

    Do you know, why the server is just seen locally?
    (I did nmap from a remote host in my LAN and netstat also shows the server
    listening)

    Christian
     
    Christian von Essen, Jun 21, 2004
    #1
    1. Advertisements

  2. Christian von Essen wrote:
    > I initialize the sockets the following way:
    > self._addr = socket.gethostname()
    > self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    > self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
    > True)
    > self.socket.bind((self._addr, self._port))
    > self.socket.listen(self._backlog)


    What does self._addr look like? Its supposed to be '' and not 'localhost',
    otherwise the bind will only bind to the lo-interface.

    Regards,

    Diez
     
    Diez B. Roggisch, Jun 21, 2004
    #2
    1. Advertisements

  3. On Mon, 21 Jun 2004 17:59:46 +0200, Diez B. Roggisch wrote:
    >
    > What does self._addr look like? Its supposed to be '' and not 'localhost',
    > otherwise the bind will only bind to the lo-interface.
    >
    > Regards,
    >
    > Diez



    It was my hostname, so bind was just to lo-interface - now it's working,
    thanks a lot

    Christian
     
    Christian von Essen, Jun 21, 2004
    #3
    1. Advertisements

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. Jiong Feng
    Replies:
    0
    Views:
    1,224
    Jiong Feng
    Nov 19, 2003
  2. Alex
    Replies:
    4
    Views:
    820
    Hasani Blackwell
    Feb 8, 2005
  3. =?Utf-8?B?S2VuTGVl?=
    Replies:
    5
    Views:
    2,989
  4. EdwardH

    Localhost isn't localhost

    EdwardH, Sep 29, 2005, in forum: Java
    Replies:
    20
    Views:
    6,845
    Roedy Green
    Oct 1, 2005
  5. pwilkins
    Replies:
    7
    Views:
    629
    Grant Edwards
    Jun 25, 2005
  6. Giovanni Tumiati
    Replies:
    2
    Views:
    416
    Grant Edwards
    Jun 25, 2005
  7. koicat
    Replies:
    0
    Views:
    398
    koicat
    Jul 2, 2010
  8. Marc
    Replies:
    4
    Views:
    318
Loading...