Stellarium 0.15.2
Connection.hpp
1 /*
2 The stellarium telescope library helps building
3 telescope server programs, that can communicate with stellarium
4 by means of the stellarium TCP telescope protocol.
5 It also contains smaple server classes (dummy, Meade LX200).
6 
7 Author and Copyright of this file and of the stellarium telescope library:
8 Johannes Gajdosik, 2006
9 
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
23 */
24 
25 #ifndef _CONNECTION_HPP_
26 #define _CONNECTION_HPP_
27 
28 #include "Socket.hpp"
29 
31 class Connection : public Socket
32 {
33 public:
34  Connection(Server &server, SOCKET fd);
35  long long int getServerMinusClientTime(void) const
36  {
37  return server_minus_client_time;
38  }
39 
40 protected:
42  void performReading(void);
44  void performWriting(void);
45  void prepareSelectFds(fd_set &read_fds, fd_set &write_fds, int &fd_max);
46 
47 private:
49  virtual bool isTcpConnection(void) const {return true;}
51  virtual bool isAsciiConnection(void) const {return false;}
52  void handleSelectFds(const fd_set &read_fds, const fd_set &write_fds);
57  virtual void dataReceived(const char *&p, const char *read_buff_end);
61  void sendPosition(unsigned int ra_int, int dec_int, int status);
62 
63 protected:
64  char read_buff[120];
65  char *read_buff_end;
66  char write_buff[120];
67  char *write_buff_end;
68 
69 private:
70  long long int server_minus_client_time;
71 };
72 
73 #endif //_CONNECTION_HPP_
void performWriting(void)
Sends the contents of the write buffer over a TCP/IP connection.
Base class for telescope server classes.
Definition: Server.hpp:45
void performReading(void)
Receives data from a TCP/IP connection and stores it in the read buffer.
TCP/IP connection to a client.
Definition: Connection.hpp:31