[3/3] ws2_32: Implement WSASendMsg() (try 2)

Alexandre Julliard julliard at winehq.org
Mon Sep 30 04:32:59 CDT 2013


Bruno Jesus <00cpxxx at gmail.com> writes:

> @@ -2427,6 +2427,46 @@ static void WINAPI WS2_GetAcceptExSockaddrs(PVOID buffer, DWORD data_size, DWORD
>  }
>  
>  /***********************************************************************
> + *     WSASendMsg
> + */
> +int WINAPI WSASendMsg( SOCKET s, LPWSAMSG msg, DWORD dwFlags, LPDWORD lpNumberOfBytesSent,
> +                       LPWSAOVERLAPPED lpOverlapped,
> +                       LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
> +{
> +    int ret = SOCKET_ERROR, fd, sock_type;
> +    socklen_t optlen = sizeof(sock_type);
> +
> +    if (!msg)
> +    {
> +        SetLastError(WSAEFAULT);
> +        return SOCKET_ERROR;
> +    }
> +
> +    if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
> +        return SOCKET_ERROR;
> +
> +    if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &sock_type, &optlen) == -1)
> +    {
> +        SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno());
> +        goto cleanup;
> +    }
> +
> +    if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW)
> +    {
> +        SetLastError(WSAEINVAL);
> +        goto cleanup;
> +    }
> +
> +    ret = WS2_sendto( s, msg->lpBuffers, msg->dwBufferCount, lpNumberOfBytesSent,
> +                         dwFlags, msg->name, msg->namelen,
> +                         lpOverlapped, lpCompletionRoutine );

This is redundant, WS2_sendto will already fetch the file descriptor,
any necessary error checking should happen there.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list