Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't receive message with Zeromq PGM protocol

Tags:

c#

zeromq

I'm trying to create a server/client zeromq based PUB-SUB using PGM protocol, all on my local computer.

For some reason I get stuck on:

string a = clientsocket.Receive(Encoding.Unicode);

It's just for the test and I don't get an exception, the program simply waits.

Server code:

var context = ZmqContext.Create();
ZmqSocket serversocket = context.CreateSocket(SocketType.PUB);

try
{
    serversocket.Bind("epgm://192.168.137.127;224.0.0.1:5555");
}
catch (ZmqException)
{
    throw;
}

int x = 0;
Console.WriteLine("UP");

while (x < 100)
{
    serversocket.Send("hello",Encoding.Unicode);
    Console.WriteLine("hello sent {0}",x.ToString()); 
    Thread.Sleep(2000);
    x++;
}

Client code:

context = ZmqContext.Create();
clientsocket = context.CreateSocket(SocketType.SUB);

try
{
    clientsocket.Connect("epgm://192.168.137.127;224.0.0.1:5555");
}
catch (ZmqException)
{
    throw;
}

clientsocket.SubscribeAll();
clientsocket.ReceiveReady += PollingItemEvens;

string a = clientsocket.Receive(Encoding.Unicode);

if (a == "hello")
{
   Application.Run(_form1);
}

var poller = new Poller(new List<ZmqSocket> {clientsocket});

while (true)
{
    poller.Poll();
}

Edit [2014-08-04 1640 UTC+0000]

i have changed the epgm IP after reading the documentation. yet it didnt solve the problem...

my IPv4 is 192.168.137.127

its a hotspot seance im on a laptop, it makes any different?

and can i see the epgm on 'netstat' on windwos cmd? because i dont see anything

like image 839
Doron Eli Avatar asked Feb 13 '23 08:02

Doron Eli


1 Answers

You should take a look at the pgm/epgm documentation for 0MQ:

In particular:

Connecting a socket

When connecting a socket to a peer address using zmq_connect() with the pgm or epgm transport, the endpoint shall be interpreted as an interface followed by a semicolon, followed by a multicast address, followed by a colon and a port number.

An interface may be specified by either of the following:

•The interface name as defined by the operating system.

•The primary IPv4 address assigned to the interface, in its numeric representation.

Interface names are not standardised in any way and should be assumed to be arbitrary and platform dependent. On Win32 platforms no short interface names exist, thus only the primary IPv4 address may be used to specify an interface.

A multicast address is specified by an IPv4 multicast address in its numeric representation.

If you follow the documentation, an address of "epgm://224.0.0.1:8200" is invalid: it is missing the interface part of the address.

like image 167
Falanwe Avatar answered Feb 15 '23 10:02

Falanwe