Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendaytime.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/daytime.c 00005 * PURPOSE: Sends the current date and time to the client 00006 * COPYRIGHT: Copyright 2005 - 2008 Ged Murphy <gedmurphy@reactos.org> 00007 * 00008 */ 00009 00010 #include "tcpsvcs.h" 00011 00012 static BOOL 00013 SendTime(SOCKET sock, CHAR *time) 00014 { 00015 DWORD stringSize = strlen(time) + 1; 00016 if (send(sock, time, stringSize, 0) == SOCKET_ERROR) 00017 { 00018 LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR); 00019 return FALSE; 00020 } 00021 00022 return TRUE; 00023 } 00024 00025 00026 DWORD WINAPI 00027 DaytimeHandler(VOID* Sock_) 00028 { 00029 struct tm *localTime; 00030 time_t aclock; 00031 CHAR *pszTime; 00032 DWORD retVal = 0; 00033 SOCKET Sock = (SOCKET)Sock_; 00034 00035 time(&aclock); 00036 localTime = localtime(&aclock); 00037 if (localTime) 00038 { 00039 pszTime = asctime(localTime); 00040 if (!SendTime(Sock, pszTime)) 00041 retVal = 1; 00042 } 00043 00044 LogEvent(L"DayTime: Shutting connection down", 0, 0, LOG_FILE); 00045 if (ShutdownConnection(Sock, FALSE)) 00046 LogEvent(L"DayTime: Connection is down", 0, 0, LOG_FILE); 00047 else 00048 { 00049 LogEvent(L"DayTime: Connection shutdown failed", 0, 0, LOG_FILE); 00050 retVal = 1; 00051 } 00052 00053 LogEvent(L"DayTime: Terminating thread", 0, 0, LOG_FILE); 00054 ExitThread(retVal); 00055 } Generated on Sun May 27 2012 04:17:54 for ReactOS by
1.7.6.1
|