mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 10:12:58 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
68
base/services/tcpsvcs/discard.c
Normal file
68
base/services/tcpsvcs/discard.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* PROJECT: ReactOS simple TCP/IP services
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/services/tcpsvcs/discard.c
|
||||
* PURPOSE: Receives input from a client and discards it
|
||||
* COPYRIGHT: Copyright 2005 - 2008 Ged Murphy <gedmurphy@reactos.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tcpsvcs.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
static BOOL
|
||||
ReceiveIncomingPackets(SOCKET sock)
|
||||
{
|
||||
CHAR readBuffer[BUFSIZE];
|
||||
INT readBytes;
|
||||
|
||||
do
|
||||
{
|
||||
readBytes = recv(sock, readBuffer, BUFSIZE, 0);
|
||||
if (readBytes > 0)
|
||||
{
|
||||
TCHAR logBuf[256];
|
||||
|
||||
swprintf(logBuf, L"Discard: Received %d bytes from client", readBytes);
|
||||
LogEvent(logBuf, 0, 0, LOG_FILE);
|
||||
}
|
||||
else if (readBytes == SOCKET_ERROR)
|
||||
{
|
||||
LogEvent(L"Discard: Socket Error", WSAGetLastError(), 0, LOG_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
} while ((readBytes > 0) && (!bShutdown));
|
||||
|
||||
if (!bShutdown)
|
||||
LogEvent(L"Discard: Connection closed by peer", 0, 0, LOG_FILE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
DiscardHandler(VOID* sock_)
|
||||
{
|
||||
DWORD retVal = 0;
|
||||
SOCKET sock = (SOCKET)sock_;
|
||||
|
||||
if (!ReceiveIncomingPackets(sock))
|
||||
{
|
||||
LogEvent(L"Discard: ReceiveIncomingPackets failed", 0, 0, LOG_FILE);
|
||||
retVal = 1;
|
||||
}
|
||||
|
||||
LogEvent(L"Discard: Shutting connection down", 0, 0, LOG_FILE);
|
||||
if (ShutdownConnection(sock, TRUE))
|
||||
{
|
||||
LogEvent(L"Discard: Connection is down.", 0, 0, LOG_FILE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogEvent(L"Discard: Connection shutdown failed", 0, 0, LOG_FILE);
|
||||
retVal = 1;
|
||||
}
|
||||
|
||||
LogEvent(L"Discard: Terminating thread", 0, 0, LOG_FILE);
|
||||
ExitThread(retVal);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue