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 _OSRTSOCKET_H_
00030 #define _OSRTSOCKET_H_
00031
00032 #ifndef _OS_NOSOCKET
00033
00034
00035 #ifdef _MSC_VER
00036 #pragma warning(disable: 4514)
00037 #endif
00038
00039 #include "rtxsrc/rtxSocket.h"
00040
00050 class EXTRTCLASS OSRTSocket {
00051 protected:
00052 OSRTSOCKET mSocket;
00053 int mInitStatus;
00054 int mStatus;
00055 OSBOOL mOwner;
00056
00057 inline OSBOOL isInitialized () { return mInitStatus == 0; }
00058
00059 public:
00067 EXTRTMETHOD OSRTSocket ();
00068
00078 EXTRTMETHOD OSRTSocket (OSRTSOCKET socket, OSBOOL ownership = FALSE);
00079
00084 EXTRTMETHOD OSRTSocket (const OSRTSocket& socket);
00085
00090 EXTRTMETHOD ~OSRTSocket ();
00091
00107 EXTRTMETHOD OSRTSocket* accept (OSIPADDR* destIP = 0, int *port = 0);
00108
00119 EXTRTMETHOD static const char* addrToString
00120 (OSIPADDR ipAddr, char* pAddrStr, size_t bufsize);
00121
00136 EXTRTMETHOD int bind (OSIPADDR addr, int port);
00137
00150 EXTRTMETHOD int bindUrl (const char* url);
00151
00168 EXTRTMETHOD int bind (const char* pAddrStr, int port);
00169
00183 inline int bind (int port) {
00184 return bind (OSIPADDR_ANY, port);
00185 }
00186
00198 EXTRTMETHOD int blockingRead (OSOCTET* pbuf, size_t readBytes);
00199
00208 EXTRTMETHOD int close ();
00209
00225 EXTRTMETHOD int connect (const char* host, int port);
00226
00238 EXTRTMETHOD int connectUrl (const char* url);
00239
00246 OSBOOL getOwnership () { return mOwner; }
00247
00253 OSRTSOCKET getSocket () const { return mSocket; }
00254
00262 inline int getStatus () { return mStatus; }
00263
00275 EXTRTMETHOD int listen (int maxConnections);
00276
00290 EXTRTMETHOD int recv (OSOCTET* pbuf, size_t bufsize);
00291
00301 inline void setOwnership (OSBOOL ownership) { mOwner = ownership; }
00302
00315 EXTRTMETHOD int send (const OSOCTET* pdata, size_t size);
00316
00328 EXTRTMETHOD static OSIPADDR stringToAddr (const char* pAddrStr);
00329 } ;
00330
00333 #endif
00334
00335 #endif //_OSRTSOCKET_H_