• Register
0 votes
2.4k views

Problem :

I am facing the issue with the client and server codes, I keep on getting the [Errno 10061] No connection could be made because the target machine actively refused it

I am running the server on a VM with Windows XP SP3 and my client is on Windows 7 64bit, also my python version is 2.7.3. I want to know is how can I edit the existing code to be able to use the client and server on different networks.

My server 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, ' >> ', msg
  msg = raw_input('SERVER >> ')
  c.send(msg);
  #c.close()                # Close the connection

My client 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 >> ')
  s.send(msg)
  msg = s.recv(1024)
  print 'SERVER >> ', msg
#s.close                     # Close the socket when done
6 5 3
6,930 points

1 Answer

0 votes

Solution :

1) You need to first change directory to root drive C:\, and type the following command into an admin cmd prompt window,

C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg –install

2) After that type net start MongoDB after which you must see the following message:

"The Mongo DB service was started successfully"

3) Then go to the your control panel and go to Start>Administrative Tools>Services, scroll down up to MongoDB in the list of services and please make sure you change the start up type to automatic. Press OK.

4) Finally you need to type C:\mongodb\bin\mongo.exe and you will be connected to the Mongo test DB.

And your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 10 views
10 views
7 I have a problem with these client and server codes, I keep getting the [Errno 10061] No connection could be made because the target machine actively refused it I'm running the server on a virtual machine with Windows XP SP3 and the client on Windows 7 64bit, my python version is ... msg) msg = s.recv(1024) print 'SERVER >> ', msg #s.close # Close the socket when done PS : code is from internet.
asked Oct 25 psandprop 2.4k points
0 votes
1 answer 96 views
96 views
Problem : I am trying to use the WCF4.0 template -REST. Also I am trying to make the method that uploads a file using the stream. The problem always occur at below line of code: Stream myserverStream = myrequest.GetRequestStream() ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
asked Dec 10, 2019 alecxe 7.5k points
1 vote
1 answer 178 views
178 views
Problem: I am beginner to ruby on rails. Recently I have started learning ruby on rails in depth. I am trying to use the ruby on rails to develop my website but I am facing below error whenever I try to open the localhost. could not connect to server: Connection refused ... can’t fix the error so now I am looking for help from ruby on rails expert to give me the quick fix for above error.
asked May 18 Martin K 6.6k points
0 votes
1 answer 227 views
227 views
Problem : I am not very sure how can I fix the below issue I have really no idea about why am I facing below error while trying to do the runserver: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread ... server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
asked Dec 25, 2019 alecxe 7.5k points