Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

concreteconnection.h

Go to the documentation of this file.
00001 /*
00002  * concreteconnection.h,v 1.16 2003/12/27 19:46:23 matti Exp
00003  *
00004  * COBAIN - Communications API for EPOC Environments
00005  * Copyright (C) 2002-2003 Matti Dahlbom, Matti Kokkola
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but 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 library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Contact: Matti Dahlbom <matti@777-team.org>
00022  *          Matti Kokkola <matti.kokkola@iki.fi>
00023  */
00024 
00025 #ifndef __CONCRETE_CONNECTION_H
00026 #define __CONCRETE_CONNECTION_H
00027 
00028 #include <e32base.h>
00029 #include <es_sock.h>
00030 
00031 #include "serversession.h"
00032 
00033 // forward declarations
00034 class CAsynchSend;
00035 class CAsynchReceive;
00036 class CAsynchListen;
00037 
00048 class CConcreteConnection : public CBase
00049 {
00050     public:
00051         enum TConnectionFailure {
00052             ENoSocket = 67000,
00053             ESocketClosed,
00054             EBadMessage
00055         };
00056 
00057         enum TInitError {
00058             ENullSocket = 68000,
00059             ENullSocketServ
00060         };
00061 
00062         static CConcreteConnection * NewL(RSocket *aSocket, 
00063                                           CServerSession &aSession,
00064                       TInt aMtu);
00065         static CConcreteConnection * NewListeningL(RSocket *aSocket,
00066                                                    RSocketServ *aSocketServ,
00067                                                    CServerSession &aSession);
00068 
00069         CServerSession& GetSession() { return iSession; }
00070         ~CConcreteConnection();
00071 
00072         TBool IsListening() { return iIsListening; }
00073 
00074         void ReceiveL(const RMessage &aMessage);
00075         void CancelReceive();
00076 
00083         void Close(TBool aImmediately = EFalse);
00084 
00085         void SendL(TDesC8 *aBuf);
00086         void ListenL(const RMessage &aMessage);
00087         void CancelListen();
00088     TInt GetMTU();
00089 
00090     protected:
00091         void ConstructL(TBool aIsListening);
00092         CConcreteConnection(RSocket* aSocket,
00093                             RSocketServ *aSocketServ, 
00094                             CServerSession &aSession,
00095                 TInt aMtu);
00096 
00097         // asynchronous send handler
00098         CAsynchSend *iSender;
00099 
00100         // asynchronous listen handler
00101         CAsynchListen *iListener;
00102 
00103     // asynchronous receive handler
00104     CAsynchReceive *iReceiver;
00105 
00106     private:
00107         RSocket& GetSocket() { return *iSocket; }
00108         RSocketServ& GetSocketServ() { return *iSocketServ; }
00109 
00110         // whether this connection is a listening connection
00111         TBool iIsListening;
00112 
00113         // whether this connection has already been closed
00114         TBool iIsClosed;
00115 
00116         // the session that owns this connection
00117         CServerSession &iSession;
00118 
00119         // actual socket resources
00120         RSocket* iSocket;
00121         RSocketServ *iSocketServ;
00122     
00123     // Maximum transfer unit of this connection
00124     TInt iMtu;
00125 
00126         friend class CAsynchSend;
00127         friend class CAsynchListen;
00128     friend class CAsynchReceive;
00129 };
00130 
00131 #endif

Generated on Tue Jan 13 15:47:07 2004 for CobainAPIImplementation by doxygen 1.3.5