monotone

monotone Mtn Source Tree

Root/netxx/serverbase.h

1/*
2 * Copyright (C) 2001-2004 Peter J Jones (pjones@pmade.org)
3 * All Rights Reserved
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name of the Author nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
23 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/** @file
34 * This file contains the defintion of the Netxx::ServerBase class.
35**/
36
37#ifndef _netxx_serverbase_h_
38#define _netxx_serverbase_h_
39
40// Netxx includes
41#include <netxx/types.h>
42#include <netxx/timeout.h>
43#include <netxx/probe.h>
44#include <netxx/probeinfo.h>
45#include "socket.h"
46#include "probe_impl.h"
47
48// standard includes
49#include <string>
50#include <vector>
51#include <map>
52
53namespace Netxx {
54 class Address;
55
56/**
57 * The Netxx::ServerBase class implements common server code for other Netxx
58 * server classes.
59**/
60class ServerBase {
61public:
62
63 explicit ServerBase (const Timeout &timeout=Timeout());
64
65 virtual ~ServerBase (void);
66
67 void bind_to(const Address &addr, bool stream_server);
68
69 void get_socket_list (Socket *&sockets, size_type &size);
70
71 Socket* get_readable_socket (void);
72
73 void set_timeout (const Timeout &timeout);
74
75 const Timeout& get_timeout (void) const;
76
77 bool has_socket (socket_type socketfd) const;
78
79 const ProbeInfo* get_probe_info (void) const;
80private:
81 Timeout timeout_;
82 Socket *sockets_;
83 size_type sockets_size_;
84 std::map<socket_type, Socket*> sockets_map_;
85 std::vector<std::string> files_;
86
87 ProbeInfo pi_;
88 Probe probe_;
89
90 ServerBase (const ServerBase&);
91 ServerBase& operator= (const ServerBase&);
92
93}; // end Netxx::ServerBase class
94} // end Netxx namespace
95#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status