tags:

views:

28

answers:

1

I am learning how to use the boost asio libraries and I am using the UDP examples on visual studio 2008. I have compiled and run the server application(name udp_server.exe). I have tried to run the client application but is does connect to the server. How do I specify the host and service name to the application for it to connect. I have specified the machine name but I get an error "No connection could be made because the target machine actively refused it". Are there some prerequisite setup I need to perform on my Windows 7 machine to get the examples to work?

+3  A: 

Assuming that you are referring to the "Daytime.4 - A synchronous UDP daytime client" example, the server's host name is passed as argv1 (the first command-line parameter) to the udp::resolver::query ctor. As you can see from the docs, the port is passed as the 3rd parameter to the ctor. This parameter can be a string representation of the port number or a "service name". Quoting the docs about this:

On POSIX systems, service names are typically defined in the file /etc/services. On Windows, service names may be found in the file c:\windows\system32\drivers\etc\services.

If all this seems ok and connection still fails, check the firewall settings on the server to make sure that it allows connections on the chosen port.

Éric Malenfant
Got it. Thanks.
MeThinks