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

oscl_socket_imp_pv.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef OSCL_SOCKET_IMP_PV_H_INCLUDED
00004 #define OSCL_SOCKET_IMP_PV_H_INCLUDED
00005 
00006 #include "oscl_socket_imp_base.h"
00007 
00015 #define PVSOCK_ERR_BAD_PARAM (-1)
00016 #define PVSOCK_ERR_SOCK_NOT_OPEN (-2)
00017 #define PVSOCK_ERR_SOCK_NO_SERV (-3)
00018 #define PVSOCK_ERR_SERV_NOT_CONNECTED (-4)
00019 #define PVSOCK_ERR_SOCK_NOT_CONNECTED (-5)
00020 #define PVSOCK_ERR_NOT_IMPLEMENTED (-6)
00021 #define PVSOCK_ERR_NOT_SUPPORTED (-7)
00022 
00023 
00024 class OsclSocketServI;
00025 class PVLogger;
00026 class OsclSocketServRequestQElem;
00027 
00030 class OsclSocketI: public OsclSocketIBase
00031 {
00032     public:
00033         static OsclSocketI* NewL(Oscl_DefAlloc &a);
00034         ~OsclSocketI();
00035 
00036         //synchronous methods
00037         int32 Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol);
00038         int32 Open(OsclSocketServI& aServer);
00039         int32 Bind(OsclNetworkAddress& anAddr);
00040         int32 SetSockOpt(TPVSocketOptionLevel aOptionLevel, TPVSocketOptionName aOptionName, OsclAny* aOptionValue, int32 aOptionLen);
00041         int32 GetPeerName(OsclNetworkAddress& peerName);
00042         int32 Join(OsclNetworkAddress& anAddr);
00043         int32 Close();
00044         int32 Listen(uint32 qSize);
00045         int32 SetRecvBufferSize(uint32 size);
00046         TPVSocketEvent ThreadLogoff();
00047         TPVSocketEvent ThreadLogon(OsclSocketServI* aServ);
00048 
00049         //asynchronous methods.
00050 
00051         void Connect(ConnectParam& , OsclSocketRequestAO&);
00052 
00053         void Accept(AcceptParam &, OsclSocketRequestAO&);
00054 
00055         void Shutdown(ShutdownParam &, OsclSocketRequestAO&);
00056 
00057         void Send(SendParam &, OsclSocketRequestAO&);
00058         void SendSuccess(SendParam &);
00059 
00060         void SendTo(SendToParam & , OsclSocketRequestAO&);
00061         void SendToSuccess(SendToParam &);
00062 
00063         void Recv(RecvParam &, OsclSocketRequestAO&);
00064         void RecvSuccess(RecvParam &);
00065 
00066         void RecvFrom(RecvFromParam &, OsclSocketRequestAO&);
00067         void RecvFromSuccess(RecvFromParam &);
00068 
00069 
00070     private:
00071         OsclSocketI(Oscl_DefAlloc &a);
00072 
00073         inline void CancelConnect();
00074         inline void CancelAccept();
00075         inline void CancelShutdown();
00076         inline void CancelSend();
00077         inline void CancelSendTo();
00078         inline void CancelRecv();
00079         inline void CancelRecvFrom();
00080 
00081         inline bool IsOpen();
00082         int32 GetOsclSockOptLevelName(const TPVSocketOptionLevel aOptionLevel, const TPVSocketOptionName aOptionName, int32& aOsclOptionLevel, int32& aOsclOptionName);
00083 
00084 
00085         //PV socket server
00086 
00087         //the OS-level socket
00088         TOsclSocket iSocket;
00089 
00090     public:
00091         TOsclSocket Socket()
00092         {
00093             return iSocket;
00094         }
00095         static bool MakeAddr(OsclNetworkAddress& in, TOsclSockAddr& addr);
00096         static void MakeAddr(TOsclSockAddr& in, OsclNetworkAddress& addr);
00097         static bool MakeMulticastGroupInformation(OsclIpMReq& in, TIpMReq& addr);
00098         static void MakeMulticastGroupInformation(TIpMReq& in, OsclIpMReq& addr);
00099 
00100         //routines to handle each type of socket request under the
00101         //server thread.
00102         void ProcessConnect(OsclSocketServRequestQElem*);
00103         void ProcessShutdown(OsclSocketServRequestQElem*);
00104         void ProcessAccept(OsclSocketServRequestQElem*);
00105         void ProcessSendTo(OsclSocketServRequestQElem*);
00106         void ProcessRecvFrom(OsclSocketServRequestQElem*);
00107         void ProcessSend(OsclSocketServRequestQElem*);
00108         void ProcessRecv(OsclSocketServRequestQElem*);
00109 
00110     private:
00111         bool iSocketValid;
00112         bool iSocketConnected;
00113         void InitSocket(bool valid);
00114 
00115         bool IsConnected(OsclSocketRequestAO& aObject);
00116         bool IsReady(OsclSocketRequestAO& aObject);
00117 
00118         //server requests
00119         OsclSocketRequest iSockServAcceptRequest;
00120         OsclSocketRequest iSockServConnectRequest;
00121         OsclSocketRequest iSockServRecvRequest;
00122         OsclSocketRequest iSockServRecvFromRequest;
00123         OsclSocketRequest iSockServSendRequest;
00124         OsclSocketRequest iSockServSendToRequest;
00125         OsclSocketRequest iSockServShutdownRequest;
00126         friend class OsclAcceptRequest;
00127         friend class OsclConnectRequest;
00128         friend class OsclRecvRequest;
00129         friend class OsclRecvFromRequest;
00130         friend class OsclSendRequest;
00131         friend class OsclSendToRequest;
00132         friend class OsclShutdownRequest;
00133 
00134         friend class OsclUDPSocket;
00135         friend class OsclTCPSocket;
00136 
00137         PVLogger* iLogger;
00138 
00139     public:
00140         //for logging in socket request list.
00141         PVLogger* Logger()
00142         {
00143             return iLogger;
00144         }
00145 
00146 };
00147 
00148 #endif
00149 
00150 
00151 
00152 

OSCL API
Posting Version: CORE_8.000.1.1_RC4