2 * PROJECT: ReactOS simple TCP/IP services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: /base/services/tcpsvcs/discard.c
5 * PURPOSE: Recieves input from a client and discards it
6 * COPYRIGHT: Copyright 2005 - 2008 Ged Murphy <gedmurphy@reactos.org>
15 RecieveIncomingPackets(SOCKET sock
)
17 CHAR readBuffer
[BUFSIZE
];
22 readBytes
= recv(sock
, readBuffer
, BUFSIZE
, 0);
27 _swprintf(logBuf
, L
"Discard: Received %d bytes from client", readBytes
);
28 LogEvent(logBuf
, 0, 0, LOG_FILE
);
30 else if (readBytes
== SOCKET_ERROR
)
32 LogEvent(L
"Discard: Socket Error", WSAGetLastError(), 0, LOG_ERROR
);
35 } while ((readBytes
> 0) && (!bShutdown
));
38 LogEvent(L
"Discard: Connection closed by peer", 0, 0, LOG_FILE
);
44 DiscardHandler(VOID
* sock_
)
47 SOCKET sock
= (SOCKET
)sock_
;
49 if (!RecieveIncomingPackets(sock
))
51 LogEvent(L
"Discard: RecieveIncomingPackets failed", 0, 0, LOG_FILE
);
55 LogEvent(L
"Discard: Shutting connection down", 0, 0, LOG_FILE
);
56 if (ShutdownConnection(sock
, TRUE
))
58 LogEvent(L
"Discard: Connection is down.", 0, 0, LOG_FILE
);
62 LogEvent(L
"Discard: Connection shutdown failed", 0, 0, LOG_FILE
);
66 LogEvent(L
"Discard: Terminating thread", 0, 0, LOG_FILE
);