Nanomsg TCP Handshake

I also posted this in the Arduino section, but this problem is most likely caused by my ignorance of nanomsg and connections in general, not an Arduino problem.

I am trying to communicate with a server that uses nanomsg to communicate over TCP on a port using Arduino. I tried different configurations (remote arduino connection and arduino connection to server using various nanomsg tools).

I can get the Arduino in server mode (a very slightly modified version of the WiFiWebServer example works) to successfully read the text that I send using cat

sudo cat texttosend > /dev/tcp/192.168.1.50/80

      

However, in all configurations and no matter what text I try to send with nanomsg, I always get the same line numbers. When printing bytes as hex from arduino, they are 0 53 50 0 0 51 0 0. Nanosg (a simple command line tool nanomsg) hangs instead of sending and shutting down (for example, it constantly tries to confirm the connection before sending data).

I am guessing it is some kind of handshake that the Arduino fails because the client connects, reads those bytes, then shuts down and restarts. Using nanomsg on both ends (from my local machine to the server) works great.

If these numbers I am getting are a handshake, how can I do that?

Ball of the looped part of the Arduino code

client = server.available();
if (client) {
  Serial.println("new client");
  while (client.connected()) {
    while (client.available()) {
      byte b = client.read();
      Serial.print(b,HEX);
      Serial.write(b);
    }
  }
 }

      

And the nanocat command that hangs when trying to connect,

nanocat --push --connect tcp://192.168.1.50:80 --data thismesadsfsdfg

      

+3


source to share


1 answer


The following text describes the nanomsg protocol for TCP .



In it you can see why you are receiving the specified stream of bytes and what you should write before the text you want to send.

+2


source







All Articles