… | |
… | |
32 | #include <sys/types.h> |
32 | #include <sys/types.h> |
33 | #include <sys/uio.h> |
33 | #include <sys/uio.h> |
34 | #include <sys/socket.h> |
34 | #include <sys/socket.h> |
35 | |
35 | |
36 | #ifndef CMSG_SPACE |
36 | #ifndef CMSG_SPACE |
37 | # define CMSG_SPACE(len) (sizeof (cmsghdr) + len) |
37 | # define CMSG_SPACE(len) (sizeof (struct cmsghdr) + len) |
38 | #endif |
38 | #endif |
39 | |
39 | |
40 | #ifndef CMSG_LEN |
40 | #ifndef CMSG_LEN |
41 | # define CMSG_LEN(len) (sizeof (cmsghdr) + len) |
41 | # define CMSG_LEN(len) (sizeof (struct cmsghdr) + len) |
42 | #endif |
42 | #endif |
43 | |
43 | |
44 | #endif |
44 | #endif |
45 | |
45 | |
46 | #if defined(WIN32) |
46 | #if defined(WIN32) |
… | |
… | |
189 | msg.msg_iovlen = 1; |
189 | msg.msg_iovlen = 1; |
190 | msg.msg_control = buf; |
190 | msg.msg_control = buf; |
191 | msg.msg_controllen = CMSG_SPACE (sizeof (int)); |
191 | msg.msg_controllen = CMSG_SPACE (sizeof (int)); |
192 | |
192 | |
193 | if (recvmsg (socket, &msg, 0) <= 0) |
193 | if (recvmsg (socket, &msg, 0) <= 0) |
|
|
194 | { |
|
|
195 | free (buf); |
194 | return -1; |
196 | return -1; |
|
|
197 | } |
195 | |
198 | |
196 | int fd = -1; |
199 | int fd = -1; |
197 | errno = EDOM; |
200 | errno = EDOM; |
198 | |
201 | |
199 | struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); |
202 | struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); |