2 * PROJECT: ReactOS simple TCP/IP services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: /base/services/tcpsvcs/daytime.c
5 * PURPOSE: Sends the current date and time to the client
6 * COPYRIGHT: Copyright 2005 - 2008 Ged Murphy <gedmurphy@reactos.org>
13 SendTime(SOCKET sock
, CHAR
*time
)
15 DWORD stringSize
= strlen(time
) + 1;
16 if (send(sock
, time
, stringSize
, 0) == SOCKET_ERROR
)
18 LogEvent(L
"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR
);
27 DaytimeHandler(VOID
* Sock_
)
33 SOCKET Sock
= (SOCKET
)Sock_
;
36 localTime
= localtime(&aclock
);
39 pszTime
= asctime(localTime
);
40 if (!SendTime(Sock
, pszTime
))
44 LogEvent(L
"DayTime: Shutting connection down", 0, 0, LOG_FILE
);
45 if (ShutdownConnection(Sock
, FALSE
))
46 LogEvent(L
"DayTime: Connection is down", 0, 0, LOG_FILE
);
49 LogEvent(L
"DayTime: Connection shutdown failed", 0, 0, LOG_FILE
);
53 LogEvent(L
"DayTime: Terminating thread", 0, 0, LOG_FILE
);