00001
00002
00003
00004
00005
00006
00007
00018 #ifndef OSCL_SOCKET_H_INCLUDED
00019 #define OSCL_SOCKET_H_INCLUDED
00020
00021 #ifndef OSCLCONFIG_IO_H_INCLUDED
00022 #include "osclconfig_io.h"
00023 #endif
00024
00025 #ifndef OSCL_SOCKET_TYPES_H_INCLUDED
00026 #include "oscl_socket_types.h"
00027 #endif
00028
00029 #ifndef OSCL_HEAPBASE_H_INCLUDED
00030 #include "oscl_heapbase.h"
00031 #endif
00032
00033 #ifndef OSCL_DEFALLOC_H_INCLUDED
00034 #include "oscl_defalloc.h"
00035 #endif
00036
00037 #ifndef OSCL_VECTOR_H_INCLUDED
00038 #include "oscl_vector.h"
00039 #endif
00040
00041 #ifndef OSCL_MEM_H_INCLUDED
00042 #include "oscl_mem.h"
00043 #endif
00044
00048 class OsclSocketServI;
00049
00050 class OsclSocketServ : public HeapBase
00051 {
00052 public:
00060 OSCL_IMPORT_REF static OsclSocketServ *NewL(Oscl_DefAlloc &alloc);
00061
00066 OSCL_IMPORT_REF ~OsclSocketServ();
00067
00076 OSCL_IMPORT_REF int32 Connect(uint32 aMessageSlots = 8);
00077
00086 OSCL_IMPORT_REF void Close(bool aCleanup = true);
00087
00088 private:
00089 OsclSocketServ(Oscl_DefAlloc &alloc): iServ(NULL), iAlloc(alloc) {}
00090
00091 OsclSocketServI *iServ;
00092 Oscl_DefAlloc &iAlloc;
00093
00094 friend class OsclTCPSocket;
00095 friend class OsclUDPSocket;
00096 friend class OsclDNS;
00097
00098 };
00099
00100
00101 class OsclUDPSocketI;
00102
00107 class OsclUDPSocket : public HeapBase
00108 {
00109 public:
00122 OSCL_IMPORT_REF static OsclUDPSocket *NewL(Oscl_DefAlloc &alloc,
00123 OsclSocketServ& aServ,
00124 OsclSocketObserver *aObserver,
00125 uint32 aId);
00126
00131 OSCL_IMPORT_REF ~OsclUDPSocket();
00132
00145 OSCL_IMPORT_REF int32 Close();
00146
00155 OSCL_IMPORT_REF int32 Bind(OsclNetworkAddress& aAddress);
00156
00167 OSCL_IMPORT_REF int32 Join(OsclNetworkAddress& aAddress);
00168
00182 OSCL_IMPORT_REF TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress
00183 , int32 aTimeoutMsec = (-1));
00184
00193 OSCL_IMPORT_REF void CancelBind();
00194
00204 OSCL_IMPORT_REF uint8 *GetRecvData(int32 *aLength);
00205
00215 OSCL_IMPORT_REF uint8 *GetSendData(int32 *aLength);
00216
00232 OSCL_IMPORT_REF TPVSocketEvent SendTo(const uint8* aPtr, uint32 aLen,
00233 OsclNetworkAddress& aAddress,
00234 int32 aTimeoutMsec = -1);
00243 OSCL_IMPORT_REF void CancelSendTo();
00244
00274 OSCL_IMPORT_REF TPVSocketEvent RecvFrom(uint8* aPtr, uint32 aMaxLen,
00275 OsclNetworkAddress& aAddress,
00276 int32 aTimeoutMsec = -1,
00277 uint32 aMultiRecvLimit = 0,
00278 Oscl_Vector<uint32, OsclMemAllocator>* aPacketLen = NULL,
00279 Oscl_Vector<OsclNetworkAddress, OsclMemAllocator>* aPacketSource = NULL);
00288 OSCL_IMPORT_REF void CancelRecvFrom();
00289
00299 OSCL_IMPORT_REF int32 SetRecvBufferSize(uint32 size);
00300
00301 private:
00302 OsclUDPSocket(Oscl_DefAlloc &alloc): iUDPSocket(NULL), iAlloc(alloc) {}
00303 OsclUDPSocketI *iUDPSocket;
00304 Oscl_DefAlloc &iAlloc;
00305 };
00306
00307 class OsclTCPSocketI;
00308
00313 class OsclTCPSocket : public HeapBase
00314 {
00315 public:
00328 OSCL_IMPORT_REF static OsclTCPSocket *NewL(Oscl_DefAlloc &alloc,
00329 OsclSocketServ& aServ,
00330 OsclSocketObserver *aObserver,
00331 uint32 aId);
00332
00337 OSCL_IMPORT_REF ~OsclTCPSocket();
00338
00339
00352 OSCL_IMPORT_REF int32 Close();
00353
00362 OSCL_IMPORT_REF int32 Bind(OsclNetworkAddress& aAddress);
00363
00377 OSCL_IMPORT_REF TPVSocketEvent BindAsync(OsclNetworkAddress& aAddress
00378 , int32 aTimeoutMsec = (-1));
00379
00388 OSCL_IMPORT_REF void CancelBind();
00389
00398 OSCL_IMPORT_REF int32 Listen(int32 aQueueSize);
00399
00413 OSCL_IMPORT_REF TPVSocketEvent ListenAsync(int32 aQueueSize, int32 aTimeoutMsec = (-1));
00414
00423 OSCL_IMPORT_REF void CancelListen();
00424
00437 OSCL_IMPORT_REF OsclTCPSocket *GetAcceptedSocketL(uint32 aId);
00438
00448 OSCL_IMPORT_REF uint8 *GetRecvData(int32 *aLength);
00449
00459 OSCL_IMPORT_REF uint8 *GetSendData(int32 *aLength);
00460
00474 OSCL_IMPORT_REF TPVSocketEvent Connect(OsclNetworkAddress& aAddress,
00475 int32 aTimeoutMsec = -1);
00476
00485 OSCL_IMPORT_REF void CancelConnect();
00486
00500 OSCL_IMPORT_REF TPVSocketEvent Shutdown(TPVSocketShutdown aHow,
00501 int32 aTimeoutMsec = -1);
00502
00511 OSCL_IMPORT_REF void CancelShutdown();
00512
00525 OSCL_IMPORT_REF TPVSocketEvent Accept(int32 aTimeout = -1);
00526
00535 OSCL_IMPORT_REF void CancelAccept();
00536
00551 OSCL_IMPORT_REF TPVSocketEvent Send(const uint8* aPtr, uint32 aLen,
00552 int32 aTimeoutMsec = -1);
00553
00562 OSCL_IMPORT_REF void CancelSend();
00563
00578 OSCL_IMPORT_REF TPVSocketEvent Recv(uint8* aPtr, uint32 aMaxLen,
00579 int32 aTimeoutMsec = -1);
00580
00589 OSCL_IMPORT_REF void CancelRecv();
00590
00591 private:
00592 static OsclTCPSocket *NewL(Oscl_DefAlloc &alloc, OsclTCPSocketI* aSocket);
00593
00594 private:
00595 OsclTCPSocket(Oscl_DefAlloc &alloc): iTCPSocket(NULL), iAlloc(alloc) {}
00596 OsclTCPSocketI *iTCPSocket;
00597 Oscl_DefAlloc &iAlloc;
00598 };
00599
00600 #endif
00601
00602