diff options
author | Patrick Simianer <p@simianer.de> | 2015-03-25 15:23:41 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-03-25 15:23:41 +0100 |
commit | 9aa075c79122709d8d5b8adf8c91ebd348eac658 (patch) | |
tree | 90d59e442881801fbf51de0ba5a5582c2049d9b3 /decoder/network_decoder.cc | |
parent | 4ce8dd5d091d63fcafddb447475ae36f769fd8c5 (diff) |
updated network_decoder
Diffstat (limited to 'decoder/network_decoder.cc')
-rw-r--r-- | decoder/network_decoder.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/decoder/network_decoder.cc b/decoder/network_decoder.cc index aaa1842d..ebbb91b5 100644 --- a/decoder/network_decoder.cc +++ b/decoder/network_decoder.cc @@ -28,7 +28,7 @@ struct TheObserver : public DecoderObserver int send(nn::socket& sock, const string trans) { - cout << "sending translation '" << trans << "'" << endl; + cout << "sending translation '" << trans << "'" << endl << endl; sock.send(trans.c_str(), trans.size()+1, 0); } @@ -36,10 +36,11 @@ bool recv(nn::socket& sock, string& source) { char *buf = NULL; - sock.recv(&buf, NN_MSG, 0); + size_t sz = sock.recv(&buf, NN_MSG, 0); if (buf) { - string s(buf); + string s(buf, buf+sz); source = s; + nn::freemsg(buf); return true; } @@ -62,6 +63,8 @@ loop(Decoder& decoder, nn::socket& sock) cout << "received source '" << source << "'" << endl; decoder.Decode(source, &o); send(sock, o.translation); + } else { + // Oh no! } } } @@ -75,7 +78,8 @@ main(int argc, char** argv) SetSilent(true); nn::socket sock(AF_SP, NN_PAIR); - string url = "ipc:///tmp/network_decoder.ipc"; + //string url = "ipc:///tmp/network_decoder.ipc"; + string url = "tcp://127.0.0.1:60666"; sock.bind(url.c_str()); loop(decoder, sock); |