- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经阅读了 writev
的手册页并发现 ERRORS 部分指出
EINVAL ... the vector count
iovcnt
is less than zero or greater than the permitted maximum.
#include <stdlib.h>
#include <fcntl.h>
#include <sys/uio.h>
char content[4000];
struct iovec vec[4000];
int main()
{
int n, i;
// int cnt = 1024; // OK
int cnt = 1025; // writev error
int fd = open("tmp.txt", O_WRONLY);
if (fd == -1) {
perror("open");
exit(1);
}
for (i = 0; i < cnt; ++i) {
content[i] = 'a' + i % 26;
vec[i].iov_base = content + i;
vec[i].iov_len = 1;
}
n = writev(fd, vec, cnt);
if (n == -1) {
perror("writev");
exit(1);
}
return 0;
}
最佳答案
这是我在一些手册页中找到的内容:
POSIX.1-2001 allows an implementation to place a limit on the number of items that can be passed in iov. An implementation can advertise its limit by defining IOV_MAX in <limits.h> or at run time via the return value from sysconf(_SC_IOV_MAX). On Linux, the limit advertised by these mechanisms is 1024, which is the true kernel limit. However, the glibc wrapper functions do some extra work if they detect that the underlying kernel system call failed because this limit was exceeded.
关于c - "iovcnt"中 "writev"参数的允许最大值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27271801/
这是man writev说: The data transfers performed by readv() and writev() are atomic: the data written by
我正在研究 writev 和 readv,当我显示内存内容时,我得到了奇怪的数据: struct iovec *iov = malloc(sizeof(struct iovec) * 3); iov[
我尝试将 writev 与 direct IO 结合起来。但是当我和他们结合时,我失败了。 下面的代码有效,但如果我在 open() 时添加 O_DIRECT 则失败 失败时我总是得到“无效参数”。
#include #include #include #include int main(int argc, char *argv[]) { int fd; fd=open(a
我已经阅读了 writev 的手册页并发现 ERRORS 部分指出 EINVAL ... the vector count iovcnt is less than zero or greater th
假设我通过TCP套接字连接到客户端,并在套接字上调用writev并包含3个项目,说“从地址A写入16个字节,从地址B写入32个字节,再从地址A写入16个字节”。 是将完整的64字节消息组装在我的机器的
希望你能帮帮我。 我正在尝试通过 TCP/IP 通过网络发送 1000 位的数据包,我希望也能够在 Cygwin 和 Windows 中使用重叠 I/O 技术。 在 Cygwin 中,我尝试使用“re
我有很多 send(fd, buf, len, MSG_DONTWAIT | MSG_NOSIGNAL) 我想合并成一个 writev(fd, iov, iovcnt) 但是,writev 无法识别
writev 函数接受一个 struct iovec 数组作为输入参数 writev(int fd, const struct iovec *iov, int iovcnt); 输入是需要写入文件(比
我在 Docker 容器中为我的项目使用 React、React-Redux 和 Webpack,但一直遇到这个错误 internal/stream_base_commons.js:59 var er
是否有适用于 char * bufs 而不是文件描述符的 readv/writev 等效项? 例如,如果我有一个 char * buf[] 数组,并且我想将其全部复制到一个 char buf * 中。
有一个multiplayer card game我首先在 C 中将其编程为非 fork 套接字服务器(使用 poll() 调用)。 然后添加新功能对我来说太困难了,我已经切换到 Perl(使用 IO:
我正在运行旧的 Angular 应用程序:[angular/cli-1.4.5,node:10.13.0 and windows: win32 x64]。当我为我的应用程序提供服务时,它编译成功,但是
在 scatter 和 gather(即 readv 和 writev)中,Linux 读取多个缓冲区并从多个缓冲区。 如果说,我有一个包含 3 个缓冲区的向量,我可以使用 readv,或者我可以使用
我只是想使用 readv() 从文件中获取一些数据。但是总是打印垃圾字符。我试图为 iovec.iov_base 分配空间,但没有运气。我什至想到了为什么要使用 readv 函数而不是坚持使用更简单和
我有一个与 USB 交互的程序,我想知道以下写入命令告诉我什么。我知道 writev iovec 结构由数据数组指针和长度组成,但是 "@\10\335\320\2w\4\240K\252\0\7"
我是一名优秀的程序员,十分优秀!