Hey all, <div><br></div><div>I keep getting a connection error 111 connection refused. When i try to connect to a server at a remote ip address.</div><div><br></div><div>I am using linux on both computers. </div><div><br></div>
<div>the socket server looks like this:</div><div><div>#!/usr/bin/python</div><div>import SocketServer</div><div><br></div><div>class MyTCPHandler(SocketServer.BaseRequestHandler):</div><div> </div><div> def handle(self):</div>
<div> self.data = self.request.recv(1024).strip()</div><div> print "%s wrote:" % self.client_address[0]</div><div> print self.data</div><div> # just send back the same data, but upper-cased</div>
<div> self.request.send(self.data.upper())</div><div><br></div><div>if __name__ == "__main__":</div><div> HOST, PORT = "127.0.0.1", 3000</div><div><br></div><div> # Create the server, binding to localhost on port 9999</div>
<div> server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)</div><div><br></div><div> # Activate the server; this will keep running until you</div><div> # interrupt the program with Ctrl-C</div><div> server.serve_forever()</div>
<div><br></div><div><br></div><div>and the client looks like this:</div><div><br></div><div><div>#!/usr/bin/python</div><div><br></div><div>import socket</div><div>import sys </div><div><br></div><div>HOST, PORT = "ip.address.of.server", 3000</div>
<div>data = "hello world"</div><div><br></div><div># Create a socket (SOCK_STREAM means a TCP socket)</div><div>sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</div><div><br></div><div># Connect to server and send data</div>
<div>sock.connect((HOST, PORT))</div><div>sock.send(data + "\n")</div><div><br></div><div># Receive data from the server and shut down</div><div>received = sock.recv(1024)</div><div>sock.close()</div><div><br></div>
<div>print "Sent: %s" % data</div><div>print "Received: %s" % received</div><div><br></div><div>the server starts fine on the remote computer, but the client dies immediatly when executed ( to time to find the server, i don't think) with the connection refused error.</div>
<div>The port forwarding is set up correctly on both computers, i know because i have another app that runs on 3000 ( but is not running when i am trying this)</div><div><br></div><div>any tips would be greatly appreciated,</div>
<div>thanks</div><div><br></div><div>sk</div><div><br></div></div></div>