1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 19 20 #ifndef OSCL_SOCKET_IMP_BASE_H_INCLUDED 21 #define OSCL_SOCKET_IMP_BASE_H_INCLUDED 22 23 #include "oscl_socket_types.h" 24 #include "oscl_socket_request.h" 25 #include "oscl_defalloc.h" 26 #include "oscl_mutex.h" 27 #include "oscl_socket_stats.h" 28 #include "oscl_base.h" 29 30 class OsclSocketServI; 31 32 /*! Socket implementation base class 33 */ 34 class OsclSocketIBase 35 { 36 public: 37 virtual ~OsclSocketIBase(); 38 39 //synchronous methods 40 virtual int32 Open(OsclSocketServI& aServer, uint32 addrFamily, uint32 sockType, uint32 protocol) = 0; 41 virtual int32 Open(OsclSocketServI& aServer) = 0; 42 virtual int32 Bind(OsclNetworkAddress& anAddr) = 0; 43 virtual int32 Join(OsclNetworkAddress& anAddr) = 0; 44 virtual int32 Close() = 0; 45 virtual int32 Listen(uint32 qSize) = 0; 46 47 //asynchronous methods. 48 virtual void Connect(ConnectParam& , OsclSocketRequestAO&) = 0; 49 50 virtual void Accept(AcceptParam &, OsclSocketRequestAO&) = 0; 51 52 virtual void Shutdown(ShutdownParam &, OsclSocketRequestAO&) = 0; 53 54 virtual void Send(SendParam &, OsclSocketRequestAO&) = 0; 55 virtual void SendSuccess(SendParam &) = 0; 56 57 virtual void SendTo(SendToParam & , OsclSocketRequestAO&) = 0; 58 virtual void SendToSuccess(SendToParam &) = 0; 59 60 virtual void Recv(RecvParam &, OsclSocketRequestAO&) = 0; 61 virtual void RecvSuccess(RecvParam &) = 0; 62 63 virtual void RecvFrom(RecvFromParam &, OsclSocketRequestAO&) = 0; 64 virtual void RecvFromSuccess(RecvFromParam &) = 0; 65 66 //optional async methods BindAsync(BindParam &,OsclSocketRequestAO &)67 virtual void BindAsync(BindParam&, OsclSocketRequestAO&) 68 {} ListenAsync(ListenParam &,OsclSocketRequestAO &)69 virtual void ListenAsync(ListenParam&, OsclSocketRequestAO&) 70 {} 71 static bool HasAsyncBind() ; 72 static bool HasAsyncListen() ; 73 74 void CancelFxn(TPVSocketFxn); 75 76 protected: 77 OsclSocketIBase(Oscl_DefAlloc &a); 78 79 virtual void CancelConnect() = 0; 80 virtual void CancelAccept() = 0; 81 virtual void CancelShutdown() = 0; 82 virtual void CancelSend() = 0; 83 virtual void CancelSendTo() = 0; 84 virtual void CancelRecv() = 0; 85 virtual void CancelRecvFrom() = 0; 86 87 //optional methods, for async bind/listen CancelBind()88 virtual void CancelBind() 89 {} CancelListen()90 virtual void CancelListen() 91 {} 92 93 Oscl_DefAlloc &iAlloc; 94 95 static int GetShutdown(TPVSocketShutdown aOsclVal); 96 97 virtual bool IsOpen() = 0; 98 99 //link to socket server. 100 OsclSocketServI *iSocketServ; 101 friend class OsclSocketRequest; 102 friend class OsclSocketMethod; 103 friend class OsclSocketRequestAO; 104 105 #if(PV_OSCL_SOCKET_STATS_LOGGING) 106 OsclSocketStats iStats; 107 #endif 108 109 friend class OsclUDPSocket; 110 friend class OsclTCPSocket; 111 }; 112 113 #endif 114 115 116 117