I am trying to receive ancillary data via UNIX domain sockets using the following code.
struct iovec iov = {
.iov_base = &app->req,
.iov_len = sizeof(app->req) - app->req_rx,
};
union {
char buf[CMSG_SPACE(sizeof(int))];
struct cmsghdr align;
} u;
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_control = u.buf,
.msg_controllen = sizeof(u.buf),
.msg_flags = 0,
};
rx = recvmsg(app->fd, &msg, 0);
Here, recvmsg fails and returns -1, and the reason is "Bad Address". Any reason as to why this might be happening.
question from:
https://stackoverflow.com/questions/65932481/recvmsg-fails-with-bad-address 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…