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
00033 #ifdef _MSC_VER
00034 #pragma warning(disable: 4514)
00035 #endif
00036
00037 #include "rtxsrc/rtxSocket.h"
00038
00048 class EXTRTCLASS OSRTSocket {
00049 protected:
00050 OSRTSOCKET mSocket;
00051 int mInitStatus;
00052 int mStatus;
00053 OSBOOL mOwner;
00054
00055 inline OSBOOL isInitialized () { return mInitStatus == 0; }
00056
00057 public:
00065 EXTRTMETHOD OSRTSocket ();
00066
00076 EXTRTMETHOD OSRTSocket (OSRTSOCKET socket, OSBOOL ownership = FALSE);
00077
00082 EXTRTMETHOD OSRTSocket (const OSRTSocket& socket);
00083
00088 EXTRTMETHOD ~OSRTSocket ();
00089
00105 EXTRTMETHOD OSRTSocket* accept (OSIPADDR* destIP = 0, int *port = 0);
00106
00117 EXTRTMETHOD static const char* addrToString
00118 (OSIPADDR ipAddr, char* pAddrStr, size_t bufsize);
00119
00134 EXTRTMETHOD int bind (OSIPADDR addr, int port);
00135
00148 EXTRTMETHOD int bindUrl (const char* url);
00149
00166 EXTRTMETHOD int bind (const char* pAddrStr, int port);
00167
00181 inline int bind (int port) {
00182 return bind (OSIPADDR_ANY, port);
00183 }
00184
00196 EXTRTMETHOD int blockingRead (OSOCTET* pbuf, size_t readBytes);
00197
00206 EXTRTMETHOD int close ();
00207
00223 EXTRTMETHOD int connect (const char* host, int port);
00224
00236 EXTRTMETHOD int connectUrl (const char* url);
00237
00244 OSBOOL getOwnership () { return mOwner; }
00245
00251 OSRTSOCKET getSocket () const { return mSocket; }
00252
00260 inline int getStatus () { return mStatus; }
00261
00273 EXTRTMETHOD int listen (int maxConnections);
00274
00288 EXTRTMETHOD int recv (OSOCTET* pbuf, size_t bufsize);
00289
00299 inline void setOwnership (OSBOOL ownership) { mOwner = ownership; }
00300
00313 EXTRTMETHOD int send (const OSOCTET* pdata, size_t size);
00314
00326 EXTRTMETHOD static OSIPADDR stringToAddr (const char* pAddrStr);
00327 } ;
00328
00331 #endif //_OSRTSOCKET_H_