I would like to transfer messages back and forth between Android and Python using ZMQ. I'm using NetMQ/ZMQ to do so. Following is my Requester code.
public class Requester : RunAbleThread
{
protected override void Run()
{
ForceDotNet.Force();
using (RequestSocket client = new RequestSocket())
{
client.Connect("tcp://localhost:5556");
for (int i = 0; i < 10 && Running; i++)
{
Debug.Log("Sending Hello");
client.SendFrame("Hello");
string message = null;
bool gotMessage = false;
while (Running)
{
gotMessage = client.TryReceiveFrameString(out message);
if (gotMessage) break;
}
if (gotMessage) Debug.Log("Received " + message);
}
}
NetMQConfig.Cleanup();
}
}
Following is my receiver's code.
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5556")
while True:
# Wait for next request from client
message = socket.recv()
print("Received request: %s" % message)
socket.send(b"World")
The above code works perfectly fine in Editor mode. However, when I run the same code in Android, the requester is not receiving any messages at all. What am I missing? Both devices are connected to the same WIFI hotspot.