XmlRpcServer.h
Go to the documentation of this file.
1 // this file modified by Morgan Quigley on 22 Apr 2008.
2 // added features: server can be opened on port 0 and you can read back
3 // what port the OS gave you
4 
5 #ifndef _XMLRPCSERVER_H_
6 #define _XMLRPCSERVER_H_
7 //
8 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
9 //
10 #if defined(_MSC_VER)
11 # pragma warning(disable:4786) // identifier was truncated in debug info
12 #endif
13 
14 #ifndef MAKEDEPEND
15 # include <map>
16 # include <string>
17 # include <vector>
18 # ifndef _WINDOWS
19 # include <poll.h>
20 # endif
21 #endif
22 
24 #include "xmlrpcpp/XmlRpcSource.h"
25 #include "xmlrpcpp/XmlRpcDecl.h"
26 
27 namespace XmlRpc {
28 
29 
30  // An abstract class supporting XML RPC methods
31  class XmlRpcServerMethod;
32 
33  // Class representing connections to specific clients
34  class XmlRpcServerConnection;
35 
36  // Class representing argument and result values
37  class XmlRpcValue;
38 
39 
42  public:
44  XmlRpcServer();
46  virtual ~XmlRpcServer();
47 
49  void enableIntrospection(bool enabled=true);
50 
52  void addMethod(XmlRpcServerMethod* method);
53 
55  void removeMethod(XmlRpcServerMethod* method);
56 
58  void removeMethod(const std::string& methodName);
59 
61  XmlRpcServerMethod* findMethod(const std::string& name) const;
62 
65  bool bindAndListen(int port, int backlog = 5);
66 
68  void work(double msTime);
69 
71  void exit();
72 
74  void shutdown();
75 
77  void listMethods(XmlRpcValue& result);
78 
79  // XmlRpcSource interface implementation
80 
82  virtual unsigned handleEvent(unsigned eventType);
83 
85  virtual void removeConnection(XmlRpcServerConnection*);
86 
87  inline int get_port() { return _port; }
88 
89  XmlRpcDispatch *get_dispatch() { return &_disp; }
90 
91  protected:
92 
94  virtual unsigned acceptConnection();
95 
97  virtual XmlRpcServerConnection* createConnection(int socket);
98 
100  bool enoughFreeFDs();
101 
102  // Whether the introspection API is supported by this server
104 
105  // Event dispatcher
107 
108  // Collection of methods. This could be a set keyed on method name if we wanted...
109  typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
111 
112  // system methods
115 
116  int _port;
117 
118  // Flag indicating that accept had an error and needs to be retried.
120  // If we cannot accept(), retry after this many seconds. Hopefully there
121  // will be more free file descriptors later.
122  static const double ACCEPT_RETRY_INTERVAL_SEC;
123  // Retry time for accept.
125 
126  // Minimum number of free file descriptors before rejecting clients.
127  static const int FREE_FD_BUFFER;
128 #ifndef _WINDOWS
129  // List of all file descriptors, used for counting open files.
130  std::vector<struct pollfd> pollfds;
131 #endif
132  };
133 } // namespace XmlRpc
134 
135 #endif //_XMLRPCSERVER_H_
XmlRpc::XmlRpcServer::MethodMap
std::map< std::string, XmlRpcServerMethod * > MethodMap
Definition: XmlRpcServer.h:109
XmlRpc::XmlRpcServer::_disp
XmlRpcDispatch _disp
Definition: XmlRpcServer.h:106
XmlRpc::XmlRpcServer
A class to handle XML RPC requests.
Definition: XmlRpcServer.h:41
XmlRpc::XmlRpcServer::FREE_FD_BUFFER
static const int FREE_FD_BUFFER
Definition: XmlRpcServer.h:127
XmlRpc
Definition: XmlRpcClient.h:20
XmlRpc::XmlRpcServer::get_port
int get_port()
Definition: XmlRpcServer.h:87
XmlRpc::XmlRpcServer::_accept_retry_time_sec
double _accept_retry_time_sec
Definition: XmlRpcServer.h:124
XmlRpcDecl.h
XmlRpc::XmlRpcServer::_methodHelp
XmlRpcServerMethod * _methodHelp
Definition: XmlRpcServer.h:114
XmlRpc::XmlRpcServer::_accept_error
bool _accept_error
Definition: XmlRpcServer.h:119
XmlRpc::XmlRpcSource
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
XmlRpc::XmlRpcServer::_introspectionEnabled
bool _introspectionEnabled
Definition: XmlRpcServer.h:103
XmlRpcSource.h
XmlRpc::XmlRpcServer::_methods
MethodMap _methods
Definition: XmlRpcServer.h:110
XmlRpc::XmlRpcDispatch
Definition: XmlRpcDispatch.h:25
XmlRpc::XmlRpcServerMethod
Abstract class representing a single RPC method.
Definition: XmlRpcServerMethod.h:26
XmlRpc::XmlRpcServer::_port
int _port
Definition: XmlRpcServer.h:116
XmlRpc::XmlRpcServer::ACCEPT_RETRY_INTERVAL_SEC
static const double ACCEPT_RETRY_INTERVAL_SEC
Definition: XmlRpcServer.h:122
XmlRpc::XmlRpcServer::pollfds
std::vector< struct pollfd > pollfds
Definition: XmlRpcServer.h:130
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
XmlRpc::XmlRpcServer::get_dispatch
XmlRpcDispatch * get_dispatch()
Definition: XmlRpcServer.h:89
XmlRpc::XmlRpcServer::_listMethods
XmlRpcServerMethod * _listMethods
Definition: XmlRpcServer.h:113
XmlRpc::XmlRpcServerConnection
A class to handle XML RPC requests from a particular client.
Definition: XmlRpcServerConnection.h:26
XmlRpc::XmlRpcValue
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
XmlRpcDispatch.h


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas
autogenerated on Sat Oct 17 2020 19:28:46