Replies: 1 comment
-
I personally love the simplicity of the But io_uring doesn't have them. I wonder why do we support Yeah, I know, we already have So, you can read ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags); That's what we have in And then we have these two structs: struct iovec { /* Scatter/gather array items */
void *iov_base; /* Starting address */
size_t iov_len; /* Number of bytes to transfer */
};
struct msghdr {
void *msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
size_t msg_iovlen; /* # elements in msg_iov */
void *msg_control; /* ancillary data, see below */
size_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
}; (Note, the TL;DRBy using int fd = ...;
int flags = ...;
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
char buf[N];
ssize_t ret;
ret = recvfrom(fd, buf, sizeof(buf), flags, (struct sockaddr *)&addr, &len); the above call is equivalent to: int fd = ...;
int flags = ...;
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
char buf[N];
struct msghdr msg;
struct iovec iov;
ssize_t ret;
iov.iov_base = buf;
iov.iov_len = sizeof(buf);
msg.msg_name = &addr;
msg.msg_namelen = len;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
ret = recvmsg(fd, &msg, flags); |
Beta Was this translation helpful? Give feedback.
-
When using
recvfrom
orrecvmsg
, the sender's IP address and port number can be retrieved from astruct sockaddr_in *
orstruct sockaddr_in6 *
.Now I'm reading the source file
test/send_recvmsg.c
, but I have not find a way to get that address afterio_uring_wait_cqe(ring, &cqe)
instatic int do_recvmsg(struct io_uring *ring, char buf[MAX_MSG + 1], struct recv_data *rd)
.After calling
io_uring_wait_cqe(),
cqe->user_data
is stillNULL
.So how can I get the sender's IP address and port numbers or
struct sockaddr_in *
(orstruct sockaddr_in6 *
) afterio_uring_wait_cqe()
?Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions