如果我在套接字上调用“writev”,完整的响应是在内存中创建的,还是仅在客户端中创建的?
If I call `writev` on a socket, is the full response created in memory, or only in the client?
假设我通过 TCP 套接字连接到客户端,我在套接字上调用 writev
3 个项目,说 "write 16 bytes from address A, 32 bytes from address B, and 16 more from address A again."
完整的 64 字节消息是否会在我的机器内存中组装,或者向量中的每个项目是否会在服务器上分别发送、确认和遗忘,以便完整的消息仅在插座的另一端?
Would the full, 64-byte message be assembled in the memory of my machine, or would each item in the vector be sent, acked, and forgotten on the server separately, such that the complete message is only assembled on the other end of the socket?
writev()
从向量中收集数据并将其复制到套接字发送缓冲区。如果您处于阻塞模式,它会在套接字发送缓冲区已满时阻塞。一旦进入套接字发送缓冲区,数据就会以 TCP 喜欢的任何方式发送。它可能在一个 TCP 段中,也可能一次一个字节一样糟糕。与原始向量的元素没有任何必要的相关性。
假设我通过 TCP 套接字连接到客户端,我在套接字上调用 writev
3 个项目,说 "write 16 bytes from address A, 32 bytes from address B, and 16 more from address A again."
完整的 64 字节消息是否会在我的机器内存中组装,或者向量中的每个项目是否会在服务器上分别发送、确认和遗忘,以便完整的消息仅在插座的另一端?
Would the full, 64-byte message be assembled in the memory of my machine, or would each item in the vector be sent, acked, and forgotten on the server separately, such that the complete message is only assembled on the other end of the socket?
writev()
从向量中收集数据并将其复制到套接字发送缓冲区。如果您处于阻塞模式,它会在套接字发送缓冲区已满时阻塞。一旦进入套接字发送缓冲区,数据就会以 TCP 喜欢的任何方式发送。它可能在一个 TCP 段中,也可能一次一个字节一样糟糕。与原始向量的元素没有任何必要的相关性。