SocketServer.hh

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002, 2003  ONERA
00004 //
00005 // This file is part of CERTI-libCERTI
00006 //
00007 // CERTI-libCERTI is free software ; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License
00009 // as published by the Free Software Foundation ; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // CERTI-libCERTI is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015 // Lesser General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020 // USA
00021 //
00022 // $Id: SocketServer.hh,v 3.10 2007/06/22 08:51:39 erk Exp $
00023 // ----------------------------------------------------------------------------
00024 
00025 #ifndef _CERTI_SOCKET_SERVER_HH
00026 #define _CERTI_SOCKET_SERVER_HH
00027 
00028 #include "certi.hh"
00029 #include "Socket.hh"
00030 #include "SocketTCP.hh"
00031 #include "SocketUDP.hh"
00032 #include "NetworkMessage.hh"
00033 #include "SecurityLevel.hh"
00034 #include "SecureTCPSocket.hh"
00035 
00036 #include <list>
00037 
00038 namespace certi {
00039 
00040 // ----------------------------------------------------------------------------
00042 class SocketTuple
00043 {
00044 public:
00045     Handle Federation ;
00046     FederateHandle Federate ;
00047 
00048     SocketTCP *ReliableLink ;
00049     SocketUDP *BestEffortLink ;
00050 
00051     SocketTuple(Socket *theTCPLink);
00052     ~SocketTuple();
00053 };
00054 
00055 // ----------------------------------------------------------------------------
00063 class CERTI_EXPORT SocketServer : private std::list<SocketTuple *>
00064 {
00065 public:
00066     SocketServer(SocketTCP *tcp_socket,
00067                  SocketUDP *udp_socket, int the_port);
00068 
00069     ~SocketServer();
00070 
00071     // --------------------------------
00072     // -- Connection related methods --
00073     // --------------------------------
00074     void open()
00075         throw (RTIinternalError);
00076 
00077     void close(long socket, // Provided
00078                Handle &federation_referenced, // Returned
00079                FederateHandle &federate_referenced) // Returned
00080         throw (RTIinternalError);
00081 
00082     void setReferences(long the_socket,
00083                        Handle federation_reference,
00084                        FederateHandle federate_reference,
00085                        unsigned long the_address,
00086                        unsigned int the_port)
00087         throw (RTIinternalError);
00088 
00089     // -----------------------------
00090     // -- Message related methods --
00091     // -----------------------------
00092     void checkMessage(long socket, NetworkMessage *message) const
00093         throw (SecurityError);
00094 
00095     // --------------------------
00096     // -- RTIG related methods --
00097     // --------------------------
00098     int addToFDSet(fd_set *select_fdset);
00099     Socket *getActiveSocket(fd_set *select_fdset) const ;
00100 
00101     // ------------------------------------------
00102     // -- Message Broadcasting related Methods --
00103     // ------------------------------------------
00104     Socket *getSocketLink(Handle the_federation,
00105                           FederateHandle the_federate,
00106                           TransportType the_type = RELIABLE) const
00107         throw (FederateNotExecutionMember, RTIinternalError);
00108 
00109     SocketTuple *getWithReferences(Handle the_federation,
00110                                    FederateHandle the_federate) const
00111         throw (FederateNotExecutionMember);
00112 
00113 private:
00114     // The Server socket object(used for Accepts)
00115     SocketTCP *ServerSocketTCP ;
00116     SocketUDP *ServerSocketUDP ;
00117     // int port ;
00118 
00119     // ---------------------
00120     // -- Private Methods --
00121     // ---------------------
00122     SocketTuple *getWithSocket(long socket_descriptor) const
00123         throw (RTIinternalError);
00124 };
00125 
00126 } // namespace certi
00127 
00128 #endif // _CERTI_SOCKET_SERVER_HH
00129 
00130 // $Id: SocketServer.hh,v 3.10 2007/06/22 08:51:39 erk Exp $

Generated on Thu Apr 30 15:53:50 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5