IBR-DTNSuite  0.8
ibrcommon/ibrcommon/net/tcpserver.h
Go to the documentation of this file.
00001 /*
00002  * tcpserver.h
00003  *
00004  *  Created on: 29.07.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef IBRCOMMON_TCPSERVER_H_
00009 #define IBRCOMMON_TCPSERVER_H_
00010 
00011 #include "ibrcommon/net/tcpstream.h"
00012 #include "ibrcommon/net/vinterface.h"
00013 #include <netinet/in.h>
00014 #include "ibrcommon/Exceptions.h"
00015 #include "ibrcommon/data/File.h"
00016 #include "ibrcommon/net/vsocket.h"
00017 
00018 namespace ibrcommon
00019 {
00020         class tcpserver
00021         {
00022         public:
00027                 tcpserver();
00028 
00034                 tcpserver(const ibrcommon::File &socket);
00035 
00040                 void bind(const vinterface &net, int port, bool reuseaddr = true);
00041 
00045                 void bind(int port, bool reuseaddr = true);
00046 
00051                 void listen(int connections);
00052 
00056                 virtual ~tcpserver();
00057 
00062                 tcpstream* accept();
00063 
00064                 void close();
00065                 void shutdown();
00066 
00067         private:
00068                 vsocket _socket;
00069         };
00070 }
00071 
00072 #endif /* TCPSERVER_H_ */