UDP multicast communication for the flow of events


#1

Hi

I am creating a group of applications which would communicate with each other with UDP. The interrupts on any of the two applications would be send to other and viceversa. UDP communication is used for the transmission of this events. I am struggling with creating Multicasting receiver using POCO. Has anyone implemented Multicasting receiver with POCO?

Whenever I am calling a function receiveBytes() it throws exception as invalid argument. I am not sure where to call this function as I cant use received data without that.

Below is the code

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include <string>

#include "Poco\Net\MulticastSocket.h"
#include "Poco\Net\SocketAddress.h"
#include "Poco\Net\NetException.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class EBC_ReceiverApp : public App {
  public:
	void setup() override;
	void mouseDown( MouseEvent event ) override;
	void update() override;
	void draw() override;


	void receiveData_multicast();
};



void EBC_ReceiverApp::receiveData_multicast()
{
	Poco::Net::initializeNetwork();
	try
	{
		Poco::Net::SocketAddress address("239.255.255.38", 10381);
		Poco::Net::MulticastSocket socket;
		socket.setReuseAddress(true);
		socket.setReusePort(true);
		socket.joinGroup(Poco::Net::IPAddress("239.255.255.38"));
		socket.setBlocking(false);
		char buffer[512];
	
	//	int received_bytes = socket.receiveBytes(buffer, 512);
		 cout << buffer;
		
	}
	catch (const Poco::Net::NetException e)
	{
		cout << e.what() << endl;
	}
}

void EBC_ReceiverApp::setup()
{
	//receiveData_multicast();
}

void EBC_ReceiverApp::mouseDown( MouseEvent event )
{
	//receiveData_multicast();
}

void EBC_ReceiverApp::update()
{
	//receiveData_unicast();
	//receiveData_multicast();
}

void EBC_ReceiverApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) ); 
}

CINDER_APP( EBC_ReceiverApp, RendererGl )

#2

You probably have an error in the way you call the Poco code. Have you looked at its documentation?

Since this question is not Cinder-related, you may get an answer quicker if you post your question on Stackoverflow.