[NOOB QUESTION] Dialling with push pull socket pair gives connection shutdown/refused
blakat360 opened this issue · comments
I have the following test code which works:
#include <iostream>
#include <nngpp/nngpp.h>
#include <nngpp/protocol/push0.h>
#include <nngpp/protocol/pull0.h>
using namespace std;
int main()
{
const std::string addr{"ws://127.0.0.1:9999"};
nng::socket push_socket = nng::push::open();
nng::socket pull_socket = nng::pull::open();
pull_socket.listen(addr.data());
push_socket.dial(addr.data());
push_socket.send("love yourself?");
if(auto buffer = pull_socket.recv(); buffer)
cerr << "mama! the push socket told me to:\n\t" << (const char *) buffer.release() << '\n';
return 0;
}
I now try to split this code into two programs which are running on the same local area network. The IP address are taken from ip a
.
listener:
#include <iostream>
#include <nngpp/nngpp.h>
#include <nngpp/protocol/push0.h>
#include <nngpp/protocol/pull0.h>
using namespace std;
int main()
{
const std::string addr{"ws://127.0.0.1:9999"};
nng::socket pull_socket = nng::pull::open();
pull_socket.listen(addr.data());
if(auto buffer = pull_socket.recv(); buffer)
cerr << "mama! the push socket told me to:\n\t" << (const char *) buffer.release() << '\n';
return 0;
}
dialler:
#include <iostream>
#include "nngpp/nngpp.h"
#include "nngpp/protocol/push0.h"
#include "nngpp/protocol/pull0.h"
#include <string>
using namespace std;
int main()
{
const std::string addr{"ws://192.168.1.184:9999"};
nng::socket push_socket = nng::push::open();
push_socket.dial(addr.data());
push_socket.send("love yourself?");
return 0;
}
No matter which order I start the programs in, I get either a 'Connection refused' or a 'Connection shutdown' nng::exception from the dialler and the listener never receives the message. What am I doing wrong?
it works when using 0.0.0.0 instead of 127.0.0.1