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
00022
00023 class OsclSocketServI;
00024 class PVLogger;
00025 class OsclSocketServRequestQElem;
00026
00029 class OsclSocketI: public OsclSocketIBase
00030 {
00031 public:
00032 static OsclSocketI* NewL(Oscl_DefAlloc &a);
00033 ~OsclSocketI();
00034
00035
00036 int32 Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol);
00037 int32 Open(OsclSocketServI& aServer);
00038 int32 Bind(OsclNetworkAddress& anAddr);
00039 int32 Join(OsclNetworkAddress& anAddr);
00040 int32 Close();
00041 int32 Listen(uint32 qSize);
00042 int32 SetRecvBufferSize(uint32 size);
00043
00044
00045
00046 void Connect(ConnectParam& , OsclSocketRequestAO&);
00047
00048 void Accept(AcceptParam &, OsclSocketRequestAO&);
00049
00050 void Shutdown(ShutdownParam &, OsclSocketRequestAO&);
00051
00052 void Send(SendParam &, OsclSocketRequestAO&);
00053 void SendSuccess(SendParam &);
00054
00055 void SendTo(SendToParam & , OsclSocketRequestAO&);
00056 void SendToSuccess(SendToParam &);
00057
00058 void Recv(RecvParam &, OsclSocketRequestAO&);
00059 void RecvSuccess(RecvParam &);
00060
00061 void RecvFrom(RecvFromParam &, OsclSocketRequestAO&);
00062 void RecvFromSuccess(RecvFromParam &);
00063
00064
00065 private:
00066 OsclSocketI(Oscl_DefAlloc &a);
00067
00068 inline void CancelConnect();
00069 inline void CancelAccept();
00070 inline void CancelShutdown();
00071 inline void CancelSend();
00072 inline void CancelSendTo();
00073 inline void CancelRecv();
00074 inline void CancelRecvFrom();
00075
00076 inline bool IsOpen();
00077
00078
00079
00080
00081
00082
00083 TOsclSocket iSocket;
00084
00085 public:
00086 TOsclSocket Socket()
00087 {
00088 return iSocket;
00089 }
00090 static bool MakeAddr(OsclNetworkAddress& in, TOsclSockAddr& addr);
00091 static void MakeAddr(TOsclSockAddr& in, OsclNetworkAddress& addr);
00092
00093
00094
00095 void ProcessConnect(OsclSocketServRequestQElem*);
00096 void ProcessShutdown(OsclSocketServRequestQElem*);
00097 void ProcessAccept(OsclSocketServRequestQElem*);
00098 void ProcessSendTo(OsclSocketServRequestQElem*);
00099 void ProcessRecvFrom(OsclSocketServRequestQElem*);
00100 void ProcessSend(OsclSocketServRequestQElem*);
00101 void ProcessRecv(OsclSocketServRequestQElem*);
00102
00103 private:
00104 bool iSocketValid;
00105 bool iSocketConnected;
00106 void InitSocket(bool valid);
00107
00108 bool IsConnected(OsclSocketRequestAO& aObject);
00109 bool IsReady(OsclSocketRequestAO& aObject);
00110
00111
00112 OsclSocketRequest iSockServAcceptRequest;
00113 OsclSocketRequest iSockServConnectRequest;
00114 OsclSocketRequest iSockServRecvRequest;
00115 OsclSocketRequest iSockServRecvFromRequest;
00116 OsclSocketRequest iSockServSendRequest;
00117 OsclSocketRequest iSockServSendToRequest;
00118 OsclSocketRequest iSockServShutdownRequest;
00119 friend class OsclAcceptRequest;
00120 friend class OsclConnectRequest;
00121 friend class OsclRecvRequest;
00122 friend class OsclRecvFromRequest;
00123 friend class OsclSendRequest;
00124 friend class OsclSendToRequest;
00125 friend class OsclShutdownRequest;
00126
00127 friend class OsclUDPSocket;
00128 friend class OsclTCPSocket;
00129
00130 PVLogger* iLogger;
00131
00132 public:
00133
00134 PVLogger* Logger()
00135 {
00136 return iLogger;
00137 }
00138
00139 };
00140
00141 #endif
00142
00143
00144
00145