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

oscl_tcp_socket.h

Go to the documentation of this file.
00001 
00002 #ifndef OSCL_TCP_SOCKET_H_INCLUDED
00003 #define OSCL_TCP_SOCKET_H_INCLUDED
00004 
00005 #ifndef OSCL_IP_SOCKET_H_INCLUDED
00006 #include "oscl_ip_socket.h"
00007 #endif
00008 
00009 #ifndef OSCL_DEFALLOC_H_INCLUDED
00010 #include "oscl_defalloc.h"
00011 #endif
00012 
00013 #ifndef OSCL_VECTOR_H_INCLUDED
00014 #include "oscl_vector.h"
00015 #endif
00016 
00017 #ifndef OSCL_MEM_H_INCLUDED
00018 #include "oscl_mem.h"
00019 #endif
00020 
00021 class OsclBindMethod;
00022 class OsclListenMethod;
00023 class OsclConnectMethod;
00024 class OsclShutdownMethod;
00025 class OsclAcceptMethod;
00026 class OsclSendMethod;
00027 class OsclRecvMethod;
00028 
00031 class OsclTCPSocketI : public OsclIPSocketI
00032 {
00033     public:
00034         //Synchronous methods
00035         static OsclTCPSocketI *NewL(Oscl_DefAlloc &a,
00036                                     OsclSocketServI *aServ,
00037                                     OsclSocketObserver *aObserver,
00038                                     uint32 aId);
00039 
00040         virtual ~OsclTCPSocketI();
00041 
00042         int32 Close();
00043         inline int32 Listen(int aQueueSize);
00044         //the returned value is platform-specific
00045 
00046         OsclTCPSocketI *GetAcceptedSocketL(uint32 aId);
00047 
00048         inline uint8 *GetRecvData(int32 *aLength) ;
00049         inline uint8 *GetSendData(int32 *aLength);
00050 
00051         //Asynchronous methods
00052         inline TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress,
00053                                         int32 aTimeoutMsec = -1);
00054         inline void CancelBind();
00055 
00056         inline TPVSocketEvent ListenAsync(uint32 qsize,
00057                                           int32 aTimeoutMsec = -1);
00058         inline void CancelListen();
00059 
00060         inline TPVSocketEvent Connect(OsclNetworkAddress& aAddress,
00061                                       int32 aTimeoutMsec = -1);
00062         inline void CancelConnect();
00063 
00064         inline TPVSocketEvent Shutdown(TPVSocketShutdown  aHow,
00065                                        int32 aTimeoutMsec = -1);
00066         inline void CancelShutdown();
00067 
00068         inline TPVSocketEvent Accept(int32 aTimeout = -1);
00069         inline void CancelAccept();
00070 
00071         inline TPVSocketEvent Send(const uint8* &aPtr, uint32 aLen,
00072                                    int32 aTimeoutMsec = -1);
00073         inline void CancelSend();
00074 
00075         inline TPVSocketEvent Recv(uint8* &aPtr, uint32 aMaxLen,
00076                                    int32 aTimeoutMsec = -1);
00077         inline void CancelRecv();
00078 
00079     private:
00080         static OsclTCPSocketI *NewL(Oscl_DefAlloc &a,
00081                                     OsclSocketServI *aServ,
00082                                     OsclSocketI *aSocket,
00083                                     OsclSocketObserver *aObserver,
00084                                     uint32 aId);
00085 
00086         OsclTCPSocketI(Oscl_DefAlloc &a) : OsclIPSocketI(a),
00087                 iConnectMethod(NULL),
00088                 iShutdownMethod(NULL),
00089                 iAcceptMethod(NULL),
00090                 iSendMethod(NULL),
00091                 iRecvMethod(NULL)
00092         {}
00093 
00094         void ConstructL(OsclSocketServI *aServ,
00095                         OsclSocketObserver *aObserver,
00096                         uint32 aId);
00097 
00098         void ConstructL(OsclSocketServI *aServ,
00099                         OsclSocketI *aSocket,
00100                         OsclSocketObserver *aObserver,
00101                         uint32 aId);
00102 
00103         OsclBindMethod *iBindMethod;
00104         OsclListenMethod *iListenMethod;
00105         OsclConnectMethod *iConnectMethod;
00106         OsclShutdownMethod *iShutdownMethod;
00107         OsclAcceptMethod *iAcceptMethod;
00108         OsclSendMethod *iSendMethod;
00109         OsclRecvMethod *iRecvMethod;
00110 };
00111 
00112 #include "oscl_socket_listen.h"
00113 #include "oscl_socket_recv.h"
00114 #include "oscl_socket_send.h"
00115 #include "oscl_socket_accept.h"
00116 #include "oscl_socket_shutdown.h"
00117 #include "oscl_socket_connect.h"
00118 #include "oscl_socket_bind.h"
00119 
00121 inline int32 OsclTCPSocketI::Listen(int aQueueSize)
00122 {
00123     return iSocket->Listen(aQueueSize) ;
00124 }
00125 
00127 inline uint8 *OsclTCPSocketI::GetRecvData(int32 *aLength)
00128 {
00129     return iRecvMethod->GetRecvData(aLength);
00130 }
00131 
00133 inline uint8 *OsclTCPSocketI::GetSendData(int32 *aLength)
00134 {
00135     return iSendMethod->GetSendData(aLength);
00136 }
00137 
00139 inline TPVSocketEvent OsclTCPSocketI::BindAsync(OsclNetworkAddress& aAddress,
00140         int32 aTimeout)
00141 {
00142     if (!OsclSocketIBase::HasAsyncBind())
00143         return EPVSocketFailure;//not available.
00144 
00145     iAddress.ipAddr.Set(aAddress.ipAddr.Str());
00146     iAddress.port = aAddress.port;
00147     return (iBindMethod->Bind(aAddress, aTimeout));
00148 }
00149 
00150 inline void OsclTCPSocketI::CancelBind()
00151 {
00152     iBindMethod->CancelMethod();
00153 }
00154 
00156 inline TPVSocketEvent OsclTCPSocketI::ListenAsync(uint32 qsize,
00157         int32 aTimeout)
00158 {
00159     if (!OsclSocketIBase::HasAsyncListen())
00160         return EPVSocketFailure;//not available
00161 
00162     return (iListenMethod->Listen(qsize, aTimeout));
00163 }
00164 
00165 inline void OsclTCPSocketI::CancelListen()
00166 {
00167     iListenMethod->CancelMethod();
00168 }
00169 
00171 inline TPVSocketEvent OsclTCPSocketI::Connect(OsclNetworkAddress& aAddress,
00172         int32 aTimeout)
00173 {
00174     return (iConnectMethod->Connect(aAddress, aTimeout));
00175 }
00176 
00177 inline void OsclTCPSocketI::CancelConnect()
00178 {
00179     iConnectMethod->CancelMethod();
00180 }
00181 
00183 inline TPVSocketEvent OsclTCPSocketI::Shutdown(TPVSocketShutdown  aHow,
00184         int32 aTimeout)
00185 {
00186     return (iShutdownMethod->Shutdown(aHow, aTimeout));
00187 }
00188 
00189 inline void OsclTCPSocketI::CancelShutdown()
00190 {
00191     iShutdownMethod->CancelMethod();
00192 }
00193 
00195 inline TPVSocketEvent OsclTCPSocketI::Accept(int32 aTimeout)
00196 {
00197     return (iAcceptMethod->Accept(aTimeout));
00198 }
00199 
00200 inline void OsclTCPSocketI::CancelAccept()
00201 {
00202     iAcceptMethod->CancelMethod();
00203 }
00204 
00206 inline TPVSocketEvent OsclTCPSocketI::Send(const uint8* &aPtr, uint32 aLen,
00207         int32 aTimeoutMsec)
00208 {
00209     return (iSendMethod->Send(aPtr, aLen, aTimeoutMsec));
00210 }
00211 
00212 inline void OsclTCPSocketI::CancelSend()
00213 {
00214     iSendMethod->CancelMethod();
00215 }
00216 
00218 inline TPVSocketEvent OsclTCPSocketI::Recv(uint8* &aPtr, uint32 aMaxLen,
00219         int32 aTimeout)
00220 {
00221     return (iRecvMethod->Recv(aPtr, aMaxLen, aTimeout));
00222 }
00223 
00224 inline void OsclTCPSocketI::CancelRecv()
00225 {
00226     iRecvMethod->CancelMethod();
00227 }
00228 
00229 #endif
00230 

OSCL API
Posting Version: OPENCORE_20090310