RTWinPoll.cpp revision 23bcfa32fddbe29a8c4c40d3bcfa4693a555c177
/* $Id$ */
/** @file
* NAT Network - poll(2) implementation for winsock.
*/
/*
* Copyright (C) 2013-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define LOG_GROUP LOG_GROUP_NAT_SERVICE
#include <Winsock2.h>
#include <Windows.h>
#include "winpoll.h"
static HANDLE g_hNetworkEvent;
int
{
if (g_hNetworkEvent == WSA_INVALID_EVENT)
{
}
for (unsigned int i = 0; i < nfds; ++i)
{
long eventMask = 0;
/* clean revents */
/* ignore invalid sockets */
continue;
/**
* POLLIN Data other than high priority data may be read without blocking.
* This is equivalent to ( POLLRDNORM | POLLRDBAND ).
* POLLRDBAND Priority data may be read without blocking.
* POLLRDNORM Normal data may be read without blocking.
*/
if (pollEvents & POLLIN)
/**
* POLLOUT Normal data may be written without blocking. This is equivalent
* to POLLWRNORM.
* POLLWRNORM Normal data may be written without blocking.
*/
if (pollEvents & POLLOUT)
/**
* This is "moral" equivalent to POLLHUP.
*/
}
FALSE);
if (index != WSA_WAIT_EVENT_0)
{
if (index == WSA_WAIT_TIMEOUT)
return VERR_TIMEOUT;
}
int nready = 0;
for (unsigned int i = 0; i < nfds; ++i)
{
short revents = 0;
int err;
continue;
if (err == SOCKET_ERROR)
{
if (WSAGetLastError() == WSAENOTSOCK)
{
++nready;
}
continue;
}
/* deassociate socket with event */
do { \
Log2(("sock %d: %s: %R[sockerr]\n", \
} \
} \
} while (0)
if (revents != 0)
{
++nready;
}
}
if (pNready)
return VINF_SUCCESS;
}