dlls/ws2_32/socket.c
/***********************************************************************
 *              WS2_recv                (INTERNAL)
 *
 * Workhorse for both synchronous and asynchronous recv() operations.
 */
WS2_recv                (INTERNAL)
Workhorse for both synchronous and asynchronous recv() operations.
WS2_recv ( INTERNAL ) Workhorse for both synchronous and asynchronous recv () operations .
static int WS2_recv( int fd, struct ws2_async *wsa )
{
#ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
    char pktbuf[512];
#endif
    struct msghdr hdr;
    union generic_unix_sockaddr unix_sockaddr;
    int n;
    hdr.msg_name = NULL;
    if (wsa->addr)
    {
        hdr.msg_namelen = sizeof(unix_sockaddr);
        hdr.msg_name = &unix_sockaddr;
    }
    else
        hdr.msg_namelen = 0;
    hdr.msg_iov = wsa->iovec + wsa->first_iovec;
    hdr.msg_iovlen = wsa->n_iovecs - wsa->first_iovec;
#ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
    hdr.msg_accrights = NULL;
    hdr.msg_accrightslen = 0;
#else
    hdr.msg_control = pktbuf;
    hdr.msg_controllen = sizeof(pktbuf);
    hdr.msg_flags = 0;
#endif
    if ( (n = recvmsg(fd, &hdr, wsa->flags)) == -1 )
        return -1;
#ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
    if (wsa->control)
    {
        ERR("Message control headers cannot be properly supported on this system.\n");
        wsa->control->len = 0;
    }
#else
    if (wsa->control && !convert_control_headers(&hdr, wsa->control))
    {
        WARN("Application passed insufficient room for control headers.\n");
        *wsa->lpFlags |= WS_MSG_CTRUNC;
        errno = EMSGSIZE;
        return -1;
    }
#endif
    if (wsa->addr && hdr.msg_namelen)
        ws_sockaddr_u2ws( &unix_sockaddr.addr, wsa->addr, wsa->addrlen.ptr );
    return n;
}
static int WS2_recv ( int fd , struct ws2_async * wsa ) { #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS char pktbuf [ 512 ] ; #endif struct msghdr hdr ; union generic_unix_sockaddr unix_sockaddr ; int n ; hdr . msg_name = NULL ; if ( wsa -> addr ) { hdr . msg_namelen = sizeof ( unix_sockaddr ) ; hdr . msg_name = & unix_sockaddr ; } else hdr . msg_namelen = 0 ; hdr . msg_iov = wsa -> iovec + wsa -> first_iovec ; hdr . msg_iovlen = wsa -> n_iovecs - wsa -> first_iovec ; #ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS hdr . msg_accrights = NULL ; hdr . msg_accrightslen = 0 ; #else hdr . msg_control = pktbuf ; hdr . msg_controllen = sizeof ( pktbuf ) ; hdr . msg_flags = 0 ; #endif if ( ( n = recvmsg ( fd , & hdr , wsa -> flags ) ) == -1 ) return -1 ; #ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS if ( wsa -> control ) { ERR ( " \n " ) ; wsa -> control -> len = 0 ; } #else if ( wsa -> control && ! convert_control_headers ( & hdr , wsa -> control ) ) { WARN ( " \n " ) ; * wsa -> lpFlags |= WS_MSG_CTRUNC ; errno = EMSGSIZE ; return -1 ; } #endif if ( wsa -> addr && hdr . msg_namelen ) ws_sockaddr_u2ws ( & unix_sockaddr . addr , wsa -> addr , wsa -> addrlen . ptr ) ; return n ; }
WS2_recv                (INTERNAL)
 Workhorse for both synchronous and asynchronous recv() operations.
WS2_recv ( INTERNAL ) Workhorse for both synchronous and asynchronous recv () operations .
/* if this socket is connected and lpFrom is not NULL, Linux doesn't give us
     * msg_name and msg_namelen from recvmsg, but it does set msg_namelen to zero.
     *
     * quoting linux 2.6 net/ipv4/tcp.c:
     *  "According to UNIX98, msg_name/msg_namelen are ignored
     *  on connected socket. I was just happy when found this 8) --ANK"
     *
     * likewise MSDN says that lpFrom and lpFromlen are ignored for
     * connection-oriented sockets, so don't try to update lpFrom.
     */