I am making an application that works in three different parts. One server running in C ++ and two clients running in C # and Python. The client connects to the server and sends a message.
To do this I have opted for ZeroMQ.
Because this is a POC, the code is simple.
Server Code (C++) (cppzmq)
zmq::context_t context{ 1 };
zmq::socket_t socket{ context, zmq::socket_type::rep };
socket.bind("tcp://*:5555");
zmq::message_t request;
socket.recv(request, zmq::recv_flags::none);
Python Client (pyzm)
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
socket.send(b"Hello")
C# client (NetMQ)
using(var socket = new RequestSocket())
{
socket.Connect("tcp://localhost:5555");
byte[] msg = Encoding.ASCII.GetBytes("HEllo");
socket.SendFrame(msg);
}
The connection between the Python client and the server is successful and the server receives the message sent by the client. But the connection between C # client and server is not correct. On the C # side it is assumed that you have successfully connected and transmitted the message, but the server does not reflect any changes (as if you did not receive a call).
What can be the cause?
for c# I used NetMQMessage. Does this work better for you? I use other options (no linger and timeout)
using (var client = new RequestSocket()) {
client.Connect("tcp://192.168.1.216:8000");
NetMQMessage msg = new NetMQMessage();
msg.Append("my request string buffer", Encoding.UTF8);
client.SendFrame(msg.ToString());
var res_bytes = client.ReceiveFrameBytes();
// add some function to transform bytes to string
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.