/* Change the Socket to Non Blocking */
BlockMode = TRUE;
- SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL);
+ SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &BlockMode, NULL, NULL, NULL, NULL);
Socket->SharedData->NonBlocking = TRUE;
- /* Deactive WSPEventSelect */
+ /* Deactivate WSPEventSelect */
if (Socket->SharedData->AsyncEvents)
{
if (WSPEventSelect(Handle, NULL, 0, lpErrno) == SOCKET_ERROR)
OUT LPDWORD lpdwFlags,
OUT LPINT lpErrno)
{
- PIO_STATUS_BLOCK IOSB;
- NTSTATUS Status;
PSOCKET_INFORMATION Socket;
+ BOOL Ret;
TRACE("Called (%x)\n", Handle);
*lpErrno = WSAEFAULT;
return FALSE;
}
- IOSB = (PIO_STATUS_BLOCK)&lpOverlapped->Internal;
- if (!IOSB)
- {
- if (lpErrno)
- *lpErrno = WSAEFAULT;
- return FALSE;
- }
- Status = IOSB->Status;
+ Ret = GetOverlappedResult((HANDLE)Handle, lpOverlapped, lpdwBytes, fWait);
- /* Wait for completition of overlapped */
- if (Status == STATUS_PENDING)
- {
- /* It's up to the protocol to time out recv. We must wait
- * until the protocol decides it's had enough.
- */
- if (fWait)
- {
- WaitForSingleObject(lpOverlapped->hEvent, INFINITE);
- Status = IOSB->Status;
- }
- }
-
- TRACE("Status %x Information %d\n", Status, IOSB->Information);
-
- if (Status != STATUS_PENDING)
+ if (Ret)
{
*lpdwFlags = 0;
- *lpdwBytes = IOSB->Information;
-
/* Re-enable Async Event */
SockReenableAsyncSelectEvent(Socket, FD_OOB);
SockReenableAsyncSelectEvent(Socket, FD_WRITE);
SockReenableAsyncSelectEvent(Socket, FD_READ);
}
- return Status == STATUS_SUCCESS;
+ return Ret;
}
VOID
Socket = GetSocketStructure(Handle);
if (!Socket)
{
- *lpErrno = WSAENOTSOCK;
- return SOCKET_ERROR;
+ if (lpErrno)
+ *lpErrno = WSAENOTSOCK;
+ return SOCKET_ERROR;
+ }
+ if (!lpNumberOfBytesRead && !lpOverlapped)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ if (Socket->SharedData->OobInline && ReceiveFlags && (*ReceiveFlags & MSG_OOB) != 0)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEINVAL;
+ return SOCKET_ERROR;
}
Status = NtCreateEvent( &SockEvent, EVENT_ALL_ACCESS,
}
}
- /* Verifiy if we should use APC */
+ /* Verify if we should use APC */
if (lpOverlapped == NULL)
{
}
if (lpCompletionRoutine == NULL)
{
- /* Using Overlapped Structure, but no Completition Routine, so no need for APC */
+ /* Using Overlapped Structure, but no Completion Routine, so no need for APC */
APCContext = lpOverlapped;
APCFunction = NULL;
Event = lpOverlapped->hEvent;
}
else
{
- /* Using Overlapped Structure and a Completition Routine, so use an APC */
- APCFunction = &AfdAPC; // should be a private io completition function inside us
+ /* Using Overlapped Structure and a Completion Routine, so use an APC */
+ APCFunction = &AfdAPC; // should be a private io completion function inside us
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDAPCCONTEXT));
if (!APCContext)
{
NULL,
0);
- /* Wait for completition of not overlapped */
+ /* Wait for completion of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL)
{
/* It's up to the protocol to time out recv. We must wait
Socket = GetSocketStructure(Handle);
if (!Socket)
{
- *lpErrno = WSAENOTSOCK;
- return SOCKET_ERROR;
+ if (lpErrno)
+ *lpErrno = WSAENOTSOCK;
+ return SOCKET_ERROR;
+ }
+ if (!lpNumberOfBytesRead && !lpOverlapped)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ if (Socket->SharedData->OobInline && ReceiveFlags && (*ReceiveFlags & MSG_OOB) != 0)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEINVAL;
+ return SOCKET_ERROR;
}
if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS))
}
}
- /* Verifiy if we should use APC */
+ /* Verify if we should use APC */
if (lpOverlapped == NULL)
{
}
if (lpCompletionRoutine == NULL)
{
- /* Using Overlapped Structure, but no Completition Routine, so no need for APC */
+ /* Using Overlapped Structure, but no Completion Routine, so no need for APC */
APCContext = lpOverlapped;
APCFunction = NULL;
Event = lpOverlapped->hEvent;
}
else
{
- /* Using Overlapped Structure and a Completition Routine, so use an APC */
- APCFunction = &AfdAPC; // should be a private io completition function inside us
+ /* Using Overlapped Structure and a Completion Routine, so use an APC */
+ APCFunction = &AfdAPC; // should be a private io completion function inside us
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDAPCCONTEXT));
if (!APCContext)
{
NULL,
0);
- /* Wait for completition of not overlapped */
+ /* Wait for completion of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL)
{
- WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infintely for receive...
+ WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infinitely for receive...
Status = IOSB->Status;
}
Socket = GetSocketStructure(Handle);
if (!Socket)
{
- *lpErrno = WSAENOTSOCK;
- return SOCKET_ERROR;
+ if (lpErrno)
+ *lpErrno = WSAENOTSOCK;
+ return SOCKET_ERROR;
+ }
+ if (!lpNumberOfBytesSent && !lpOverlapped)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
}
Status = NtCreateEvent( &SockEvent, EVENT_ALL_ACCESS,
}
}
- /* Verifiy if we should use APC */
+ /* Verify if we should use APC */
if (lpOverlapped == NULL)
{
/* Not using Overlapped structure, so use normal blocking on event */
}
if (lpCompletionRoutine == NULL)
{
- /* Using Overlapped Structure, but no Completition Routine, so no need for APC */
+ /* Using Overlapped Structure, but no Completion Routine, so no need for APC */
APCContext = lpOverlapped;
APCFunction = NULL;
Event = lpOverlapped->hEvent;
}
else
{
- /* Using Overlapped Structure and a Completition Routine, so use an APC */
- APCFunction = &AfdAPC; // should be a private io completition function inside us
+ /* Using Overlapped Structure and a Completion Routine, so use an APC */
+ APCFunction = &AfdAPC; // should be a private io completion function inside us
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDAPCCONTEXT));
if (!APCContext)
{
NULL,
0);
- /* Wait for completition of not overlapped */
+ /* Wait for completion of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL)
{
- WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infintely for send...
+ WaitForSingleObject(SockEvent, INFINITE); // BUGBUG, shouldn wait infinitely for send...
Status = IOSB->Status;
}
Socket = GetSocketStructure(Handle);
if (!Socket)
{
- *lpErrno = WSAENOTSOCK;
- return SOCKET_ERROR;
+ if (lpErrno)
+ *lpErrno = WSAENOTSOCK;
+ return SOCKET_ERROR;
+ }
+ if (!lpNumberOfBytesSent && !lpOverlapped)
+ {
+ if (lpErrno)
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
}
if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS))
SendInfo.TdiConnection.RemoteAddress = RemoteAddress;
SendInfo.TdiConnection.RemoteAddressLength = Socket->HelperData->MaxTDIAddressLength;
- /* Verifiy if we should use APC */
+ /* Verify if we should use APC */
if (lpOverlapped == NULL)
{
/* Not using Overlapped structure, so use normal blocking on event */
}
if (lpCompletionRoutine == NULL)
{
- /* Using Overlapped Structure, but no Completition Routine, so no need for APC */
+ /* Using Overlapped Structure, but no Completion Routine, so no need for APC */
APCContext = lpOverlapped;
APCFunction = NULL;
Event = lpOverlapped->hEvent;
}
else
{
- /* Using Overlapped Structure and a Completition Routine, so use an APC */
- APCFunction = &AfdAPC; // should be a private io completition function inside us
+ /* Using Overlapped Structure and a Completion Routine, so use an APC */
+ APCFunction = &AfdAPC; // should be a private io completion function inside us
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDAPCCONTEXT));
if (!APCContext)
{
NULL,
0);
- /* Wait for completition of not overlapped */
+ /* Wait for completion of not overlapped */
if (Status == STATUS_PENDING && lpOverlapped == NULL)
{
- /* BUGBUG, shouldn't wait infintely for send... */
+ /* BUGBUG, shouldn't wait infinitely for send... */
WaitForSingleObject(SockEvent, INFINITE);
Status = IOSB->Status;
}