Add main page for Doxygen generated documentation.
[tairent.git] / src / main / torrentserver.h
blob6f75ce1d3fdd4b53bfb2457ed3eaba215c8d3eb1
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _main_torrentserver_h
18 #define _main_torrentserver_h
20 #include <set>
22 namespace Tairon
25 namespace Net
28 class Server;
30 }; // namespace Net
32 }; // namespace Tairon
34 namespace Tairent
37 namespace Main
40 class Connection;
42 /** \brief Server accepting incomming connections for torrents.
44 class TorrentServer
46 public:
47 /** Starts the server on port specified by config key
48 * "torrent-server-port".
50 TorrentServer();
52 /** Destroys the server.
54 ~TorrentServer();
56 /** Tells the server that a handshake sequence has been successfuly
57 * completed.
59 void connectionCompleted(Connection *connection);
61 /** Returns pointer to the instance of this class.
63 static TorrentServer *self() {
64 return torrentserver;
67 /** Stops the server.
69 void stop();
71 private:
72 /** Called when a pending connection has been closed.
74 void connectionClosed(Connection *connection);
76 /** Called when a new connection arrives.
78 void newConnection(Tairon::Net::Server *, int fd);
80 private:
81 /** Set of connections that aren't fully established yet.
83 std::set<Connection *> pendingConnections;
85 /** Server object for accepting incoming connections.
87 Tairon::Net::Server *server;
89 /** Pointer to the instance of this class.
91 static TorrentServer *torrentserver;
94 }; // namespace Main
96 }; // namespace Tairent
98 #endif
100 // vim: ai sw=4 ts=4 noet fdm=marker