I created a socket server in C (using nanomsg) which shall communicate with a Python script (using standard 'Socket' implementation) via TCP:
C-Code (without error handling):
#include <nanomsg/nn.h>
#include <nanomsg/pair.h>
...
char buf[23];
...
socket = nn_socket(AF_SP, NN_PAIR);
nn_bind(socket, "tcp://127.0.0.1:xxxxx");
...
nn_recv(socket, buf, sizeof(buf), 0);
...
nn_shutdown(socket, endpoint_id);
Python-Code:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", xxxxx))
s.send('Hello C this is Python')
s.close()
There is no error in Python when connecting to the socket (if the C app is running). However, the C script is idling in method nn_recv and doesn't get any data at all. What am I doing wrong?
First I start the C code in a shell (it idles in method nn_recv). Then I start Python in another shell and expect the C application to receive the data. Both scripts execute without error.