a5215218cd14408c02d3cd4c2f9e11e512a4f311
3 * Copyright (C) 2005 ReactOS Team
5 * LICENCE: GPL - See COPYING in the top level directory
6 * PROJECT: ReactOS simple TCP/IP services
7 * FILE: apps/utils/net/tcpsvcs/discard.c
8 * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
9 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
20 DWORD WINAPI
DiscardHandler(VOID
* Sock_
)
23 SOCKET Sock
= (SOCKET
)Sock_
;
25 if (!RecieveIncomingPackets(Sock
))
27 _tprintf(_T("RecieveIncomingPackets failed\n"));
31 _tprintf(_T("Shutting connection down...\n"));
32 if (ShutdownConnection(Sock
, TRUE
))
34 _tprintf(_T("Connection is down.\n"));
38 _tprintf(_T("Connection shutdown failed\n"));
42 _tprintf(_T("Terminating discard thread\n"));
48 BOOL
RecieveIncomingPackets(SOCKET Sock
)
50 TCHAR ReadBuffer
[BUF
];
55 ReadBytes
= recv(Sock
, ReadBuffer
, BUF
, 0);
57 _tprintf(_T("Received %d bytes from client\n"), ReadBytes
);
58 else if (ReadBytes
== SOCKET_ERROR
)
60 _tprintf(("Socket Error: %d\n"), WSAGetLastError());
63 } while (ReadBytes
> 0);
65 _tprintf(("Connection closed by peer.\n"));