writev函数的使用测试

#include
#include
int main(int argc,char *argv[]){
    struct iovec outputchars[4];
    char buffer1[] = "ABCDEFG";
    char buffer2[] = "1234567";
    char buffer3[] = "890tsfy";
    char buffer4[] = "abcdefg";
    int str_len;
    outputchars[0].iov_base = buffer1;
    outputchars[0].iov_len = 3;
    outputchars[1].iov_base = buffer2;
    outputchars[1].iov_len = 4;
    outputchars[2].iov_base = buffer3;
    outputchars[2].iov_len = 5;
    outputchars[3].iov_base = buffer4;
    outputchars[3].iov_len = 6;
    str_len = writev(1,outputchars,4);
    puts("");
    printf("Write bytes:%d\n",str_len);
    return 0;
}

此文章为11月Day 19学习笔记,内容来源于极客时间《网络编程实战》。

你可能感兴趣的:(网络编程实战,网络)