Hi I'm trying to create some code based on the code of the socket tutorial of the boost website. The code to create a UDP socket which will send datagram is the following one : boost::asio::io_service io_service; udp::resolver resolver(io_service); udp::resolver::query query(udp::v4(), argv[1], "daytime"); udp::endpoint receiver_endpoint = *resolver.resolve(query); udp::socket socket(io_service); socket.open(udp::v4()); But, to send something else than a Daytime request, I need to know what are the avalaible option to put instead of "daytime" in this line : udp::resolver::query query(udp::v4(), argv[1], "daytime"); Unfortunately and as far sa I know, the documentation is quite light about that. The only that I found is this one : http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/reference/ip__basic... it is quite empty. Eventually, my goal is to use a specified port instead of a name of service. Thanks in advance for the help. Johan
udp::resolver resolver(io_service); udp::resolver::query query(udp::v4(), argv[1], "daytime"); udp::endpoint receiver_endpoint = *resolver.resolve(query);
udp::socket socket(io_service); socket.open(udp::v4());
But, to send something else than a Daytime request, I need to know what are the avalaible option to put instead of "daytime" in this line :
udp::resolver::query query(udp::v4(), argv[1], "daytime");
udp::resolver::query query(udp::v4(), "192.168.1.10", "8080");
Thanks a lot for the fast answer.
I have another question about the boost::mutable_buffer since they are used
to send and receive payload through the upd socket with the methods send_to
and receive_from.
I'd like to know how can I assign the content of a mutable_buffer to a char
* ?
I found the method buffer_cast (
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/reference/mutable_b...)
but I don't really understand how to use it.
Thanks in advance for the help.
Johan
2009/1/22 Igor R
udp::resolver resolver(io_service);
udp::resolver::query query(udp::v4(), argv[1], "daytime");
udp::endpoint receiver_endpoint = *resolver.resolve(query);
udp::socket socket(io_service); socket.open(udp::v4());
But, to send something else than a Daytime request, I need to know what are the avalaible option to put instead of "daytime" in this line :
udp::resolver::query query(udp::v4(), argv[1], "daytime");
udp::resolver::query query(udp::v4(), "192.168.1.10", "8080");
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
2009/1/23 Johan Mazel
Thanks a lot for the fast answer.
I have another question about the boost::mutable_buffer since they are used to send and receive payload through the upd socket with the methods send_to and receive_from. I'd like to know how can I assign the content of a mutable_buffer to a char * ? I found the method buffer_cast ( http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/reference/mutable_b...) but I don't really understand how to use it.
You can use it just as described here: http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/reference/buffer.ht... But in most cases you don't need this function, as you've got more safe ways to get the data (please refer to the asio tutorial and examples).
participants (2)
-
Igor R
-
Johan Mazel