Closed aslucky closed 4 years ago
It's unclear to me what your problem is. RecvMsg
just calls nng_recvmsg
. You might try re-writing the server in C# to better understand.
It looks like you're using nng.NET 1.2.4-rc0 with NNG 1.3.0. nng.NET 1.2.4-rc0 defaults to pair v1 socket while in NNG you're using nng_pair0_open
(in 1.3.0 pair v1 is deprecated). This change may help you. Related issue.
1.2.4-rc1 has this fix, but you should probably just move to 1.3.0.
thanks,I finally use pinvoke call nng.dll directly.
Wish you do this well. I close the issue
Hi,
this maybe not a bug, I am new guy with c#. I have working code in c++ and python, then I connect to c# code use pair protocol. It can connect but in c# code RecvMsg not return.
If there is a demo code should be nice. test code has some irrelevant code it's not friendly enough to show how to use. I use nng.NETCore
c++ pair client code(working)nng-1.3.0 void CnngClientDemoDlg::OnBnClickedBtnStartPair2() { nng_socket sock; char* buf = NULL; int iRet = 0; size_t sz;
}
c# pair server (not working) var path = Path.GetDirectoryName(typeof(nngTest).Assembly.Location); var ctx = new nng.NngLoadContext(path); var factory = nng.NngLoadContext.Init(ctx);
or using (var socket = factory.PairOpen().ThenListen(pair_url).Unwrap()) { var request = socket.RecvMsg().Unwrap(); var str = Encoding.ASCII.GetString(request.AsSpan()); Console.WriteLine(str); var reply = factory.CreateMessage(); var replyBytes = Encoding.ASCII.GetBytes("send msg"); reply.Append(replyBytes); socket.SendMsg(reply); }
c++ pair server (working with c++ client) nng-1.3.0 int rv; if ((rv = nng_pair0_open(&pwnd->m_sockPair)) != 0) { ASSERT(FALSE); } if ((rv = nng_listen(pwnd->m_sockPair, URL_PAIR, NULL, 0)) != 0) { ASSERT(FALSE); }