rasdaman complete source
rasmgr_comm.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
37 #ifndef RASMGR_COMM_HH
38 #define RASMGR_COMM_HH
39 
40 #include "rasmgr.hh"
41 
42 #define MAXMSG 1024
43 #define MAXMSGOUTBUFF 20000
44 
52 class HTTPComm
53 {
54 public:
55  HTTPComm();
56  ~HTTPComm();
57  void closeListenSocket();
58  void shouldExit();
59  char *decodeFlag(int statusFlag);
60 protected:
61  int initListenSocket(int port);
62  int makeSocket(int port);
63  int sendAnswer(int socket,int len);
64  int getMessage();
65 
66 protected:
67  bool isMessage(const char *messageStart);
68  // pid_t parentPID;
69  int listen_socket;
70  fd_set active_fd_set,read_fd_set;
71 
72  struct timeval tv;
73  timeval *tvptr;
74  char *header;
75  char *body;
76  char inBuffer[MAXMSG];
77  char outBuffer[MAXMSGOUTBUFF];
78 
79  bool exitRequest;
80 private:
81  int realGetMessage();
82 };
83 
84 // status flags that rasmgr understands
85 // - these come from rasserver
86 #define SERVER_DOWN 0
87 #define SERVER_AVAILABLE 1
88 #define SERVER_REGULARSIG 3
89 // - this comes from slave rasmgr and LSM
90 #define SERVER_CRASHED 2
91 
92 // textual representation of the above status flags -- PB 2004-jul-16
93 #define SERVER_DOWN_TXT "server down"
94 #define SERVER_AVAILABLE_TXT "server available"
95 #define SERVER_REGULARSIG_TXT "server alive"
96 #define SERVER_CRASHED_TXT "server aborted"
97 
98 
99 /* This two functions where written late in the night, when we came back from BLVA
100  (Bayerisches Landesvermessungsamt), where we had problems on DEC+CompaqTrue64
101  this &@$! operating system wasn't able to send a message in one piece which was written in one piece
102 */
103 int readWholeMessage(int socket,char *destBuffer,int buffSize);
104 int writeWholeMessage(int socket,char *destBuffer,int buffSize);
105 
106 #endif
int writeWholeMessage(int socket, char *destBuffer, int buffSize)
int readWholeMessage(int socket, char *destBuffer, int buffSize)