bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
PPTConnection.h
1// PPTConnection.h
2
3// This file is part of bes, A C++ back-end server implementation framework
4// for the OPeNDAP Data Access Protocol.
5
6// Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7// Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact University Corporation for Atmospheric Research at
24// 3080 Center Green Drive, Boulder, CO 80301
25
26// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27// Please read the full copyright statement in the file COPYRIGHT_UCAR.
28//
29// Authors:
30// pwest Patrick West <pwest@ucar.edu>
31// jgarcia Jose Garcia <jgarcia@ucar.edu>
32
33#ifndef PPTConnection_h
34#define PPTConnection_h 1
35
36#include "Connection.h"
37#include "PPTProtocolNames.h"
38
39class Socket;
40
41#define PPT_CHUNK_HEADER_SPACE 15
42
43class PPTConnection: public Connection {
44private:
45 int _timeout = 0;
46 char * _inBuff = nullptr;
47 int _inBuff_len = 0;
48
49 PPTConnection() = default;
50
51 virtual int readChunkHeader(char *inBuff, int buff_size);
52 void sendChunk(const std::string &buffer, std::map<std::string, std::string> &extensions) override;
53 virtual void receive(std::ostream &strm, const int len);
54
55protected:
56 explicit PPTConnection(int timeout) : _timeout(timeout) { }
57
58 virtual int readBuffer(char *inBuff, const unsigned int buff_size);
59 virtual int readBufferNonBlocking(char *inBuff, const int buff_size);
60
61 void send(const std::string &buffer) override;
62 virtual void read_extensions(std::map<std::string, std::string> &extensions, const std::string &xstr);
63
64public:
65 ~PPTConnection() override;
66
67 void initConnection() override = 0;
68 void closeConnection() override = 0;
69
70 std::string exit() override
71 {
72 return PPT_EXIT_NOW;
73 }
74
75 void send(const std::string &buffer, std::map<std::string, std::string> &extensions) override;
76 void sendExtensions(std::map<std::string, std::string> &extensions) override;
77 void sendExit() override;
78 bool receive(std::map<std::string, std::string> &extensions, std::ostream *strm = nullptr) override;
79
80 unsigned int getRecvChunkSize() override;
81 unsigned int getSendChunkSize() override;
82
83 void dump(std::ostream &strm) const override;
84};
85
86#endif // PPTConnection_h
void send(const std::string &buffer) override
sends the buffer to the socket
virtual int readBuffer(char *inBuff, const unsigned int buff_size)
read a buffer of data from the socket
void sendExtensions(std::map< std::string, std::string > &extensions) override
send the specified extensions
void sendExit() override
Send the exit token as an extension.
virtual void read_extensions(std::map< std::string, std::string > &extensions, const std::string &xstr)
the string passed are extensions, read them and store the name/value pairs into the passed map
virtual int readBufferNonBlocking(char *inBuff, const int buff_size)
read a buffer of data from the socket without blocking
void dump(std::ostream &strm) const override
dumps information about this object