00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
00098 CAsynchSend *iSender;
00099
00100
00101 CAsynchListen *iListener;
00102
00103
00104 CAsynchReceive *iReceiver;
00105
00106 private:
00107 RSocket& GetSocket() { return *iSocket; }
00108 RSocketServ& GetSocketServ() { return *iSocketServ; }
00109
00110
00111 TBool iIsListening;
00112
00113
00114 TBool iIsClosed;
00115
00116
00117 CServerSession &iSession;
00118
00119
00120 RSocket* iSocket;
00121 RSocketServ *iSocketServ;
00122
00123
00124 TInt iMtu;
00125
00126 friend class CAsynchSend;
00127 friend class CAsynchListen;
00128 friend class CAsynchReceive;
00129 };
00130
00131 #endif