From 8f27e65bddd7d4b8515ce620fb485fdd78fcdf89 Mon Sep 17 00:00:00 2001 From: Constantin Jucovschi Date: Fri, 24 Apr 2009 07:20:22 -0400 Subject: Initial commit --- rasmgr/rasmgr_comm.hh | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 rasmgr/rasmgr_comm.hh (limited to 'rasmgr/rasmgr_comm.hh') diff --git a/rasmgr/rasmgr_comm.hh b/rasmgr/rasmgr_comm.hh new file mode 100644 index 0000000..492c9c0 --- /dev/null +++ b/rasmgr/rasmgr_comm.hh @@ -0,0 +1,100 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with rasdaman community. If not, see . +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see +* or contact Peter Baumann via . +/ +/** + * SOURCE: rasmgr_comm.hh + * + * MODULE: rasmgr + * CLASS: HTTPComm + * + * PURPOSE: + * Performs reliable, but blocking HTTP communication. used by the slave rasmgr + * + * COMMENTS: + * Will be removed, the plan is to have only non-blocking communication + * +*/ + +#ifndef RASMGR_COMM_HH +#define RASMGR_COMM_HH + +#include "rasmgr.hh" + +#define MAXMSG 1024 +#define MAXMSGOUTBUFF 20000 + + +class HTTPComm + { + public: + HTTPComm(); + ~HTTPComm(); + void closeListenSocket(); + void shouldExit(); + char *decodeFlag(int statusFlag); + protected: + int initListenSocket(int port); + int makeSocket(int port); + int sendAnswer(int socket,int len); + int getMessage(); + + protected: + bool isMessage(const char *messageStart); + // pid_t parentPID; + int listen_socket; + fd_set active_fd_set,read_fd_set; + + struct timeval tv; + timeval *tvptr; + char *header; + char *body; + char inBuffer[MAXMSG]; + char outBuffer[MAXMSGOUTBUFF]; + + bool exitRequest; + private: + int realGetMessage(); + }; + +// status flags that rasmgr understands +// - these come from rasserver +#define SERVER_DOWN 0 +#define SERVER_AVAILABLE 1 +#define SERVER_REGULARSIG 3 +// - this comes from slave rasmgr and LSM +#define SERVER_CRASHED 2 + +// textual representation of the above status flags -- PB 2004-jul-16 +#define SERVER_DOWN_TXT "server down" +#define SERVER_AVAILABLE_TXT "server available" +#define SERVER_REGULARSIG_TXT "server alive" +#define SERVER_CRASHED_TXT "server aborted" + + + /* This two functions where written late in the night, when we came back from BLVA + (Bayerisches Landesvermessungsamt), where we had problems on DEC+CompaqTrue64 + this &@$! operating system wasn't able to send a message in one piece which was written in one piece + */ +int readWholeMessage(int socket,char *destBuffer,int buffSize); +int writeWholeMessage(int socket,char *destBuffer,int buffSize); + +#endif -- cgit