我在 c 中通过套接字传输 int 数组时遇到问题。htonl() 的正确用法是什么?可以说我有:
int arra[3]={6000,7000,8000};
和名为 new_socket 的套接字
我如何正确地将其传输到套接字的另一端?
客户端正在通过以下代码读取它:
char buf[BUFLEN] = ""; // buffer for recv() calls
for (i = 0; i < nbytes; i += INTLEN) {
int file_port = ntohl(*(int *)&buf[i]);