version 1.18, 2008/11/30 11:59:26 |
version 1.19, 2010/01/12 00:58:25 |
|
|
#include <sys/uio.h> |
#include <sys/uio.h> |
|
|
#include <errno.h> |
#include <errno.h> |
|
#include <poll.h> |
#include <string.h> |
#include <string.h> |
#include <stdarg.h> |
#include <stdarg.h> |
|
|
|
|
struct iovec vec; |
struct iovec vec; |
char ch = '\0'; |
char ch = '\0'; |
ssize_t n; |
ssize_t n; |
|
struct pollfd pfd; |
|
|
memset(&msg, 0, sizeof(msg)); |
memset(&msg, 0, sizeof(msg)); |
msg.msg_control = (caddr_t)&cmsgbuf.buf; |
msg.msg_control = (caddr_t)&cmsgbuf.buf; |
|
|
msg.msg_iov = &vec; |
msg.msg_iov = &vec; |
msg.msg_iovlen = 1; |
msg.msg_iovlen = 1; |
|
|
while ((n = sendmsg(sock, &msg, 0)) == -1 && (errno == EAGAIN || |
pfd.fd = sock; |
errno == EINTR)) |
pfd.events = POLLOUT; |
|
while ((n = sendmsg(sock, &msg, 0)) == -1 && |
|
(errno == EAGAIN || errno == EINTR)) { |
debug3("%s: sendmsg(%d): %s", __func__, fd, strerror(errno)); |
debug3("%s: sendmsg(%d): %s", __func__, fd, strerror(errno)); |
|
(void)poll(&pfd, 1, -1); |
|
} |
if (n == -1) { |
if (n == -1) { |
error("%s: sendmsg(%d): %s", __func__, fd, |
error("%s: sendmsg(%d): %s", __func__, fd, |
strerror(errno)); |
strerror(errno)); |
|
|
ssize_t n; |
ssize_t n; |
char ch; |
char ch; |
int fd; |
int fd; |
|
struct pollfd pfd; |
|
|
memset(&msg, 0, sizeof(msg)); |
memset(&msg, 0, sizeof(msg)); |
vec.iov_base = &ch; |
vec.iov_base = &ch; |
|
|
msg.msg_control = &cmsgbuf.buf; |
msg.msg_control = &cmsgbuf.buf; |
msg.msg_controllen = sizeof(cmsgbuf.buf); |
msg.msg_controllen = sizeof(cmsgbuf.buf); |
|
|
while ((n = recvmsg(sock, &msg, 0)) == -1 && (errno == EAGAIN || |
pfd.fd = sock; |
errno == EINTR)) |
pfd.events = POLLIN; |
|
while ((n = recvmsg(sock, &msg, 0)) == -1 && |
|
(errno == EAGAIN || errno == EINTR)) { |
debug3("%s: recvmsg: %s", __func__, strerror(errno)); |
debug3("%s: recvmsg: %s", __func__, strerror(errno)); |
|
(void)poll(&pfd, 1, -1); |
|
} |
if (n == -1) { |
if (n == -1) { |
error("%s: recvmsg: %s", __func__, strerror(errno)); |
error("%s: recvmsg: %s", __func__, strerror(errno)); |
return -1; |
return -1; |