mirror of
https://github.com/riba2534/TCP-IP-NetworkNote.git
synced 2026-07-05 20:36:03 +08:00
完成了第 13 章 多种 I/O 函数
This commit is contained in:
20
ch13/writev.c
Normal file
20
ch13/writev.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct iovec vec[2];
|
||||
char buf1[] = "ABCDEFG";
|
||||
char buf2[] = "1234567";
|
||||
int str_len;
|
||||
|
||||
vec[0].iov_base = buf1;
|
||||
vec[0].iov_len = 3;
|
||||
vec[1].iov_base = buf2;
|
||||
vec[1].iov_len = 4;
|
||||
|
||||
str_len = writev(1, vec, 2);
|
||||
puts("");
|
||||
printf("Write bytes: %d \n", str_len);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user