ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

discard.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     ReactOS simple TCP/IP services
00003  * LICENSE:     GPL - See COPYING in the top level directory
00004  * FILE:        /base/services/tcpsvcs/discard.c
00005  * PURPOSE:     Recieves input from a client and discards it
00006  * COPYRIGHT:   Copyright 2005 - 2008 Ged Murphy <gedmurphy@reactos.org>
00007  *
00008  */
00009 
00010 #include "tcpsvcs.h"
00011 
00012 #define BUFSIZE 1024
00013 
00014 static BOOL
00015 RecieveIncomingPackets(SOCKET sock)
00016 {
00017     CHAR readBuffer[BUFSIZE];
00018     INT readBytes;
00019 
00020     do
00021     {
00022         readBytes = recv(sock, readBuffer, BUFSIZE, 0);
00023         if (readBytes > 0)
00024         {
00025             TCHAR logBuf[256];
00026 
00027             _swprintf(logBuf, L"Discard: Received %d bytes from client", readBytes);
00028             LogEvent(logBuf, 0, 0, LOG_FILE);
00029         }
00030         else if (readBytes == SOCKET_ERROR)
00031         {
00032             LogEvent(L"Discard: Socket Error", WSAGetLastError(), 0, LOG_ERROR);
00033             return FALSE;
00034         }
00035     } while ((readBytes > 0) && (!bShutdown));
00036 
00037     if (!bShutdown)
00038         LogEvent(L"Discard: Connection closed by peer", 0, 0, LOG_FILE);
00039 
00040     return TRUE;
00041 }
00042 
00043 DWORD WINAPI
00044 DiscardHandler(VOID* sock_)
00045 {
00046     DWORD retVal = 0;
00047     SOCKET sock = (SOCKET)sock_;
00048 
00049     if (!RecieveIncomingPackets(sock))
00050     {
00051         LogEvent(L"Discard: RecieveIncomingPackets failed", 0, 0, LOG_FILE);
00052         retVal = 1;
00053     }
00054 
00055     LogEvent(L"Discard: Shutting connection down", 0, 0, LOG_FILE);
00056     if (ShutdownConnection(sock, TRUE))
00057     {
00058         LogEvent(L"Discard: Connection is down.", 0, 0, LOG_FILE);
00059     }
00060     else
00061     {
00062         LogEvent(L"Discard: Connection shutdown failed", 0, 0, LOG_FILE);
00063         retVal = 1;
00064     }
00065 
00066     LogEvent(L"Discard: Terminating thread", 0, 0, LOG_FILE);
00067     ExitThread(retVal);
00068 }

Generated on Fri May 25 2012 04:16:03 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.