SocketServer Problem

Ergin Aytac ergin_aytac at yahoo.de
Fri Jun 25 18:13:23 EDT 2004


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



More information about the Python-list mailing list