1

I can't send a valid request to a Server. I have this protocol description but I don't understand what thing i have to send with socat to the server.

header Must always be transmitted in full, even if the command does not require any parameters.

command This is a single letter whose case is important (commands 'A' and 'a' are very different, indeed, for example). It is 8 bit in size.

param 1 This is a 16 bit numeric parameter. It is in network byte order and mostly used to specify KNX device addresses or data lengths.

My problem comes from param. I have to send a 16 bit numeric parameter with null value. How can i do it?

ccellar
  • 10,326
  • 2
  • 38
  • 56
ShoxSpartan
  • 11
  • 1
  • 5

1 Answers1

3

Ordinarily, a "null value" just means you send zero.

If the server socket is sock, then this would send 16 bits:

send (sock, "\0\0", 2, 0);
ams
  • 24,923
  • 4
  • 54
  • 75
  • Actually, because a string literal always has a null character appended to it, `send(sock, "\0", 2, 0)` would suffice. But wouldn't it be better to build of the entire message (header, command, and parameter) into a single buffer and then `send()` the whole thing at once? – This isn't my real name Jul 17 '13 at 23:07
  • @ElchononEdelson: yes, it would better, but the OP didn't specify what to put there, and anyway I wanted to keep it simple. – ams Jul 18 '13 at 08:41