Revision e3e87df4
b/cutils.c | ||
---|---|---|
376 | 376 |
return fd; |
377 | 377 |
} |
378 | 378 |
|
379 |
static ssize_t do_sendv_recvv(int sockfd, struct iovec *iov,
|
|
380 |
size_t offset, size_t bytes,
|
|
381 |
int do_sendv)
|
|
379 |
ssize_t iov_send_recv(int sockfd, struct iovec *iov,
|
|
380 |
size_t offset, size_t bytes, |
|
381 |
bool do_sendv)
|
|
382 | 382 |
{ |
383 | 383 |
int iovlen; |
384 | 384 |
ssize_t ret; |
... | ... | |
458 | 458 |
last_iov->iov_len += diff; |
459 | 459 |
return ret; |
460 | 460 |
} |
461 |
|
|
462 |
ssize_t iov_recv(int sockfd, struct iovec *iov, size_t offset, size_t bytes) |
|
463 |
{ |
|
464 |
return do_sendv_recvv(sockfd, iov, offset, bytes, 0); |
|
465 |
} |
|
466 |
|
|
467 |
ssize_t iov_send(int sockfd, struct iovec *iov, size_t offset, size_t bytes) |
|
468 |
{ |
|
469 |
return do_sendv_recvv(sockfd, iov, offset, bytes, 1); |
|
470 |
} |
|
471 |
|
b/iov.h | ||
---|---|---|
60 | 60 |
* `offset' bytes in the beginning of iovec buffer are skipped and |
61 | 61 |
* next `bytes' bytes are used, which must be within data of iovec. |
62 | 62 |
* |
63 |
* r = iov_send(sockfd, iov, offset, bytes);
|
|
63 |
* r = iov_send_recv(sockfd, iov, offset, bytes, true);
|
|
64 | 64 |
* |
65 | 65 |
* is logically equivalent to |
66 | 66 |
* |
... | ... | |
69 | 69 |
* r = send(sockfd, buf, bytes, 0); |
70 | 70 |
* free(buf); |
71 | 71 |
*/ |
72 |
ssize_t iov_recv(int sockfd, struct iovec *iov, size_t offset, size_t bytes); |
|
73 |
ssize_t iov_send(int sockfd, struct iovec *iov, size_t offset, size_t bytes); |
|
72 |
ssize_t iov_send_recv(int sockfd, struct iovec *iov, |
|
73 |
size_t offset, size_t bytes, bool do_send); |
|
74 |
#define iov_recv(sockfd, iov, offset, bytes) \ |
|
75 |
iov_send_recv(sockfd, iov, offset, bytes, false) |
|
76 |
#define iov_send(sockfd, iov, offset, bytes) \ |
|
77 |
iov_send_recv(sockfd, iov, offset, bytes, true) |
|
74 | 78 |
|
75 | 79 |
/** |
76 | 80 |
* Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements |
Also available in: Unified diff