Forum OpenACS Development: Re: NaviServer on windows - 6th of June

Collapse
Posted by Maurizio Martignano on

This is my last input on this topic, eventually I updated the latest version on the file sock.c with this modified function:

static ssize_t
SockSend(NS_SOCKET sock, struct iovec *bufs, int nbufs, unsigned int flags)
{
    ssize_t numBytes = 0;

#ifdef _WIN32
    DWORD SendBytes = 0, Flags = (DWORD)flags;
    int rc;

    rc = WSASend(sock, (LPWSABUF)bufs, (unsigned long)nbufs, &SendBytes, Flags, NULL, NULL);
    if (rc == -1) {
        if (GetLastError() == WSAEWOULDBLOCK) {
            numBytes = 0;
        }
        else {
            numBytes = -1;
        }
    } else {
        numBytes = (ssize_t)SendBytes;
    }
#else
    struct msghdr msg;

    memset(&msg, 0, sizeof(msg));
    msg.msg_iov = bufs;
    msg.msg_iovlen = (NS_MSG_IOVLEN_T)nbufs;
    numBytes = sendmsg(sock, &msg, (int)flags);
#endif

    if (numBytes == -1) {
        Ns_Log(Debug, "SockSend: %d, %s", sock, ns_sockstrerror(ns_sockerrno));
    }

    return numBytes;
}

Hope it helps, Maurizio