title: Errno 10061 : No connection could be made because the target machine actively refused it ( client - server )
body: <p>I have a problem with these client and server codes, I keep getting the <strong>[Errno 10061] No connection could be made because the target machine actively refused it</strong> </p>
  
  <p>I'm running the server on a virtual machine with Windows XP SP3 and the client on Windows 7 64bit, my python version is 2.7.3. What I want to know is how should I edit the code to use the client and server on different networks! Thanks! </p>
  
  <p><strong>server :</strong></p>
  
  <pre><code>#!/usr/bin/python           # This is server.py file
  
  import socket               # Import socket module
  s = socket.socket()         # Create a socket object
  host = '0.0.0.0' # Get local machine name
  port = 12345                # Reserve a port for your service.
  
  
  print 'Server started!'
  print 'Waiting for clients...'
  
  s.bind((host, port))        # Bind to the port
  s.listen(5)                 # Now wait for client connection.
  c, addr = s.accept()     # Establish connection with client.
  print 'Got connection from', addr
  while True:
    msg = c.recv(1024)
    print addr, ' &gt;&gt; ', msg
    msg = raw_input('SERVER &gt;&gt; ')
    c.send(msg);
    #c.close()                # Close the connection
  </code></pre>
  
  <p><strong>client :</strong></p>
  
  <pre><code>#!/usr/bin/python           # This is client.py file
  
  import socket               # Import socket module
  
  s = socket.socket()         # Create a socket object
  host = socket.gethostname() # Get local machine name
  port = 12345                # Reserve a port for your service.
  
  print 'Connecting to ', host, port
  s.connect((host, port))
  
  while True:
    msg = raw_input('CLIENT &gt;&gt; ')
    s.send(msg)
    msg = s.recv(1024)
    print 'SERVER &gt;&gt; ', msg
  #s.close                     # Close the socket when done
  </code></pre>
  
  <p>PS : code is from internet.</p>