Byte order with a large array of characters in C

前端 未结 6 1822
梦毁少年i
梦毁少年i 2021-01-05 01:24

I am doing some socket programming in C, and trying to wrestle with byte order problems. My request (send) is fine but when I receive data my bytes are all out of order. I s

6条回答
  •  余生分开走
    2021-01-05 02:17

    It's not clear what aResponse represents (string of characters? struct?). Endianness is relevant only for numerical values, not chars. You also need to make sure that at the sender's side, all numerical values are converted from host to network byte-order (hton*).

提交回复
热议问题