00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029 #ifndef _RTXCPPSOCKET_H_
00030 #define _RTXCPPSOCKET_H_
00031
00032 #include "rtxsrc/rtxCommon.h"
00033 #include "rtxsrc/rtxCppBaseType.h"
00034 #include "rtxsrc/rtxSocket.h"
00035
00045 class EXTERNRTX OSSocketClass {
00046 private:
00047 int mInitStatus;
00048 int mStatus;
00049 protected:
00050 OSRTSOCKET mSocket;
00051 OSBOOL mOwner;
00052
00053 inline OSBOOL isInitialized () { return mInitStatus == 0; }
00054 inline int initStatus () { return mInitStatus; }
00055 public:
00060 OSSocketClass ();
00061
00071 OSSocketClass (OSRTSOCKET socket, OSBOOL ownership = FALSE);
00072
00077 OSSocketClass (const OSSocketClass& socket);
00078
00083 ~OSSocketClass ();
00084
00100 OSSocketClass* accept (OSIPADDR* destIP = 0, int *port = 0);
00101
00112 static const char* addrToString (OSIPADDR ipAddr,
00113 char* pAddrStr,
00114 int bufsize);
00115
00130 int bind (OSIPADDR addr, int port);
00131
00148 int bind (const char* pAddrStr, int port);
00149
00163 inline int bind (int port) {
00164 return bind (OSIPADDR_ANY, port);
00165 }
00166
00175 int close ();
00176
00192 int connect (const char* host, int port);
00193
00201 inline int getStatus () { return mStatus; }
00202
00208 OSRTSOCKET getSocket () const { return mSocket; }
00209
00221 int listen (int maxConnections);
00222
00236 int recv (OSOCTET* pbuf, int bufsize);
00237
00250 int send (const OSOCTET* pdata, int size);
00251
00266 static int stringToAddr (const char* pAddrStr, OSIPADDR& ipAddr);
00267 } ;
00268
00270 #endif //_RTXCPPSOCKET_H_