TCP和UDP中n的区别?

differences of n in TCP and UDP?

这是一道很好的试题, n 等于?

write(sfd,buf,1024) (server)

n = read(cfd,buf,2048) (klient)

buf 不重要,buff 的最大大小(1024 和 2048)

两者 read and write return 字节数 read/written,或 -1 出错。

请注意,为了能够在 UDP 套接字(或更一般地,在数据报套接字)上调用 read/write,您必须在其上调用 connect预先指定对等地址。