[Tutor] problem with socket connection

زياد بن عبدالعزيز الباتلي ziyad.albatly at gmail.com
Thu Dec 24 16:25:46 CET 2009


On Mon, 21 Dec 2009 12:10:01 -0600
shawn bright <nephish at gmail.com> wrote:

> Hey all,
Hi...

> 
> I keep getting a connection error 111 connection refused. When i try
> to connect to a server at a remote ip address.
The keywords here: "connection refused" and "remote ip address".

> 
> I am using linux on both computers.
> 
> the socket server looks like this:
> #!/usr/bin/python
> import SocketServer
> 
> class MyTCPHandler(SocketServer.BaseRequestHandler):
> 
>     def handle(self):
>         self.data = self.request.recv(1024).strip()
>         print "%s wrote:" % self.client_address[0]
>         print self.data
>         # just send back the same data, but upper-cased
>         self.request.send(self.data.upper())
> 
> if __name__ == "__main__":
>     HOST, PORT = "127.0.0.1", 3000
The server won't accept _any_ connections not coming from "127.0.0.1"!

You want it to accept connection from _anywhere_ use: "0.0.0.0".

----8<----

> 
> it does work if i use localhost and run both server and client on the
> same computer.
As expected.

> 
> any tips would be greatly appreciated,
> thanks
> 
> sk

Hope that helps
Ziyad.


More information about the Tutor mailing list