不
If you look for syscalls in the Linux kernel source
grep -rn SYSCALL_DEFINE.*write
查找
read
/
write
),您可以自己查看来源:
SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)
{
struct fd f = fdget_pos(fd);
ssize_t ret = -EBADF;
if (f.file) {
loff_t pos = file_pos_read(f.file);
ret = vfs_read(f.file, buf, count, &pos);
if (ret >= 0)
file_pos_write(f.file, pos);
fdput_pos(f);
}
return ret;
}
SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf,
size_t, count)
{
struct fd f = fdget_pos(fd);
ssize_t ret = -EBADF;
if (f.file) {
loff_t pos = file_pos_read(f.file);
ret = vfs_write(f.file, buf, count, &pos);
if (ret >= 0)
file_pos_write(f.file, pos);
fdput_pos(f);
}
return ret;
}
在您的情况下(即套接字),有一个预分配的每个套接字缓冲区,可能是通过动态分配的。
It's easy to check what the size is for this buffer.
Originally posted by saeedn:
/proc/sys/net/ipv4/tcp_rmem (for read)
/proc/sys/net/ipv4/tcp_wmem (for write)
还有
c
在上面的链接中提取代码中的值。
如果您试图编写超过此缓冲区大小的大量消息,则需要将其分解。通常,在向套接字写入时,您需要创建自己的套接字
write()
再次使用一部分剩余数据等。