source: BAORadio/libindi/libindi/Indi_Stellarium/src/Socket2.cpp @ 678

Last change on this file since 678 was 678, checked in by frichard, 12 years ago
File size: 1.5 KB
Line 
1/*
2The stellarium telescope library helps building
3telescope server programs, that can communicate with stellarium
4by means of the stellarium TCP telescope protocol.
5It also contains smaple server classes (dummy, Meade LX200).
6
7Author and Copyright of this file and of the stellarium telescope library:
8Johannes Gajdosik, 2006
9
10This library is free software; you can redistribute it and/or
11modify it under the terms of the GNU Lesser General Public
12License as published by the Free Software Foundation; either
13version 2.1 of the License, or (at your option) any later version.
14
15This library is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public
21License along with this library; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23*/
24
25#include "Socket2.hpp"
26
27#ifdef WIN32
28  #include <windows.h> // GetSystemTimeAsFileTime
29#else
30  #include <sys/time.h>
31#endif
32
33long long int GetNow(void)
34{
35#ifdef WIN32
36        union
37        {
38                FILETIME file_time;
39                __int64 t;
40        } tmp;
41        GetSystemTimeAsFileTime(&tmp.file_time);
42        return (tmp.t/10) - 86400000000LL*(369*365+89);
43#else
44        struct timeval tv;
45        gettimeofday(&tv, 0);
46        return tv.tv_sec * 1000000LL + tv.tv_usec;
47#endif
48}
49
50void Socket2::hangup(void)
51{
52        if (!IS_INVALID_SOCKET(fd))
53        {
54                close(fd);
55                fd = INVALID_SOCKET;
56        }
57}
58
Note: See TracBrowser for help on using the repository browser.