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 (OSIPADDR ipAddr,
00118 char* pAddrStr,
00119 int bufsize);
00120
00135 EXTRTMETHOD int bind (OSIPADDR addr, int port);
00136
00153 EXTRTMETHOD int bind (const char* pAddrStr, int port);
00154
00168 inline int bind (int port) {
00169 return bind (OSIPADDR_ANY, port);
00170 }
00171
00183 EXTRTMETHOD int blockingRead (OSOCTET* pbuf, size_t readBytes);
00184
00193 EXTRTMETHOD int close ();
00194
00210 EXTRTMETHOD int connect (const char* host, int port);
00211
00218 OSBOOL getOwnership () { return mOwner; }
00219
00225 OSRTSOCKET getSocket () const { return mSocket; }
00226
00234 inline int getStatus () { return mStatus; }
00235
00247 EXTRTMETHOD int listen (int maxConnections);
00248
00262 EXTRTMETHOD int recv (OSOCTET* pbuf, OSUINT32 bufsize);
00263
00273 inline void setOwnership (OSBOOL ownership) { mOwner = ownership; }
00274
00287 EXTRTMETHOD int send (const OSOCTET* pdata, OSUINT32 size);
00288
00300 EXTRTMETHOD static OSIPADDR stringToAddr (const char* pAddrStr);
00301 } ;
00302
00305 #endif //_OSRTSOCKET_H_