Boost logo

Boost Users :

Subject: [Boost-users] [Asio] Cannot receive a UDP multicast using receive_from
From: David Laurie (David.Laurie_at_[hidden])
Date: 2008-12-05 10:05:40


Would like to say Hello to all as I've just joined the list today and am
also a first time user of the boost libraries.

 

I'm cutting my teeth on asio by trying to receive a UDP multicast
message with the boost::asio::ip::udp::socket::receive_from function.

 

I got it going using the windows calls but just cant seem to crack it
with boost. My only suspicion is that im getting the wrong IP version in
the endpoint, but would guess it has found it from the initialisation,
but other than that im a bit stumped.

 

Any suggestions to where I may be going wrong?

 

Cheers

David

 

Heres the code:

 

const boost::asio::ip::address listen_address =

  boost::asio::ip::address::from_string("192.168.1.1");

const boost::asio::ip::address multicast_address =

  boost::asio::ip::address::from_string("224.x.x.x"); //appropriate
address used

 

boost::asio::io_service io_service;

boost::asio::ip::udp::socket socket_(io_service);

boost::asio::ip::udp::endpoint sender_endpoint_;

 

enum { max_length = 1024 };

char data_[max_length];

 

// Create the endpoint

boost::asio::ip::udp::endpoint listen_endpoint(

  listen_address,

  multicast_port);

 

// open the socket

socket_.open(listen_endpoint.protocol()); // is this picking up v6
instead of v4?

 

// Join the multicast group.

socket_.set_option(

  boost::asio::ip::multicast::join_group(multicast_address));

 

// bind it

socket_.bind(listen_endpoint);

 

socket_.receive_from(

  boost::asio::buffer(data_, max_length),

  sender_endpoint_);

This email has been scanned for all known viruses by the MessageLabs Email Security System.

Systems Engineering & Assessment Ltd - Beckington Castle, 17 Castle Corner, Beckington, Frome, Somerset, BA11 6TA, UK
is registered in England and Wales with the company number 2430846.

The contents of this email (including any attachments) are confidential and may be legally privileged.

If you are not the intended recipient of this email any disclosure, copying, distribution or use of its contents is strictly prohibited. You should notify the sender immediately and then delete it (including any attachments) from your system.

Please help out the environment by only printing this e-mail if absolutely necessary - Thank You.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net