SocketServer Problem

Discussion in 'Python' started by Ergin Aytac, Jun 25, 2004.

  1. Ergin Aytac

    Ergin Aytac Guest

    I'm trying to run a script written in python and have some socket
    connection problems. I cutted the origin script (more than 1000 lines)
    so it is only the part of the connection and there is no functionalty
    but connecting to a server.
    I have no idea about programming with python so every hint is a present
    for me :)

    ------------------------------------
    import SocketServer
    import os

    nntp_hostname = 'news.chello.at'
    nntp_port = 119

    if os.name == 'posix':
    class NNTPServer(SocketServer.ForkingTCPServer):
    allow_reuse_address = 1
    max_children = 20
    else:
    class NNTPServer(SocketServer.ThreadingTCPServer):
    allow_reuse_address = 1

    class NNTPRequestHandler(SocketServer.StreamRequestHandler):
    # this is the list of supported commands
    def handle(self):
    self.input = self.rfile.read(1024)
    print self.input

    print os.name
    print nntp_hostname
    print nntp_port

    server = NNTPServer((nntp_hostname, nntp_port), NNTPRequestHandler)
    -------------------------------------

    I get the following error on windows:
    File "D:\tmp\test\test.py", line 27, in ?
    server = NNTPServer((nntp_hostname, nntp_port), NNTPRequestHandler)
    File "D:\PYTHON23\lib\SocketServer.py", line 330, in __init__
    self.server_bind()
    File "D:\PYTHON23\lib\SocketServer.py", line 341, in server_bind
    self.socket.bind(self.server_address)
    File "<string>", line 1, in bind
    socket.error: (10049, "Can't assign requested address")

    On Linux I get the same message but the error number is 99, "Can't
    assign requested address"

    - I tried with python 2.3.2 on windows and linux
    - I tried with python 2.3.4 on windows and linux
    - I tried with other servers and ports ..
    - I tried without firewall ..
    - I tried with user root on linux ..
    - I tried with ip instead of domain name ...
    - I tried on 7 other boxes with 3 other isp with and without firewall ...
    - I also tried the original script ...

    .... but nothing changed.

    telnet works fine with every server and port I used for the tests.
    The script above worked without any error message on a box of friend.

    If you have any idea please let me know.
    thanx

    Ergin
    Ergin Aytac, Jun 25, 2004
    #1
    1. Advertising

  2. Ergin Aytac wrote:
    > nntp_hostname = 'news.chello.at'
    > nntp_port = 119



    I very much doubt it that the computer you are trying to run
    the program on, is actually called "news.chello.at"....

    > socket.error: (10049, "Can't assign requested address")


    You cannot bind a socket on an address that is not 'yours' ...

    > The script above worked without any error message on a box of friend.


    Now that is weird. Unless your friend works for Chello and his
    box is "news.chello.at"...

    --Irmen
    Irmen de Jong, Jun 26, 2004
    #2
    1. Advertising

  3. Ergin Aytac

    Ergin Aytac Guest

    The origin script is a gateway for syncronizing news on usenet servers.
    As I can see there are a lot of people who use this script for public
    usenet groups. I saw some using it for news.php.net, news.mozilla.org
    without being a part of this domains. Besides I have the access rights
    for news.chello.at which recognizes me over the domain name I'm using.
    Without any access rights I should also get access to a few public
    groups. The friend who tried this server without any errors doesn't work
    for chello and his box is not a part of chello.

    Something is strange here...

    Can I bind a socket to an address that is public and has no access
    limits? (like public usenet servers as news.php.net or news.mozilla.org)



    Irmen de Jong schrieb:
    > Ergin Aytac wrote:
    >
    >> nntp_hostname = 'news.chello.at'
    >> nntp_port = 119

    >
    >
    >
    > I very much doubt it that the computer you are trying to run
    > the program on, is actually called "news.chello.at"....
    >
    >> socket.error: (10049, "Can't assign requested address")

    >
    >
    > You cannot bind a socket on an address that is not 'yours' ...
    >
    >> The script above worked without any error message on a box of friend.

    >
    >
    > Now that is weird. Unless your friend works for Chello and his
    > box is "news.chello.at"...
    >
    > --Irmen
    Ergin Aytac, Jun 26, 2004
    #3
  4. Ergin Aytac wrote:
    > Can I bind a socket to an address that is public and has no access
    > limits? (like public usenet servers as news.php.net or news.mozilla.org)


    No.

    But you can _connect_ to it, which is a very different thing...
    Have you read the socket howto? http://www.amk.ca/python/howto/sockets/

    --Irmen
    Irmen de Jong, Jun 26, 2004
    #4
    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. Janusz
    Replies:
    4
    Views:
    1,076
    Janusz
    Jun 1, 2004
  2. lebo
    Replies:
    4
    Views:
    1,064
    Peter Hansen
    Jun 24, 2003
  3. Barry Sprajc
    Replies:
    1
    Views:
    375
    Skip Montanaro
    Aug 3, 2003
  4. UrgeOverkill
    Replies:
    2
    Views:
    431
    Peter Hansen
    Feb 19, 2004
  5. Massi
    Replies:
    0
    Views:
    241
    Massi
    Feb 28, 2011
Loading...

Share This Page