I want to send and receive very simple data (doesn't matter what form) from/to C# to/from a python program on a raspberry pi using ZeroMQ. For my server side I am using the following C# code:
using System;
using System.Threading;
using NetMQ;
using NetMQ.Sockets;
namespace NetMQServer
{
class Program
{
static void Main(string[] args)
{
using (var server = new ResponseSocket())
{
server.Bind("tcp://*:5555");
while (true)
{
Console.ReadKey();
var message = server.ReceiveFrameString();
Console.WriteLine("Received {0}", message);
// processing the request
Console.WriteLine("Sending World");
server.SendFrame("World");
}
}
}
}
}
and on the client side (python) I am using the following code:
import zmq
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://192.168.1.14:5555")
for i in range(0, 10):
print("Sending Hello")
socket.send_string("Hello")
msg = socket.recv_string()
print("recieved ", msg)
print("")
both programs run but it does not print anything in the console as if they are not connected. I have tried it with both client and server in the same language with the exact same codes above and it works.
I run your code on a local machine and cannot reproduce your issue - an interaction between client and server works fine.
Just one remark, this code:
Console.ReadKey();
should be removed from the server-side.
I would recommend:
telnet 192.168.1.14 5555
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.