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>
15 SendTime(SOCKET sock
, CHAR
*time
)
17 SIZE_T stringSize
= strlen(time
) + 1;
18 if (send(sock
, time
, stringSize
, 0) == SOCKET_ERROR
)
20 LogEvent(L
"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR
);
29 DaytimeHandler(VOID
* Sock_
)
35 SOCKET Sock
= (SOCKET
)Sock_
;
38 localTime
= localtime(&aclock
);
41 pszTime
= asctime(localTime
);
42 if (!SendTime(Sock
, pszTime
))
46 LogEvent(L
"DayTime: Shutting connection down", 0, 0, LOG_FILE
);
47 if (ShutdownConnection(Sock
, FALSE
))
48 LogEvent(L
"DayTime: Connection is down", 0, 0, LOG_FILE
);
51 LogEvent(L
"DayTime: Connection shutdown failed", 0, 0, LOG_FILE
);
55 LogEvent(L
"DayTime: Terminating thread", 0, 0, LOG_FILE
);