OSRTSocket.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1997-2010 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00024 
00029 #ifndef _OSRTSOCKET_H_
00030 #define _OSRTSOCKET_H_
00031 
00032 /* Disable MS VC++ Level 4 warning about unreferenced inline functions */
00033 #ifdef _MSC_VER
00034 #pragma warning(disable: 4514)
00035 #endif /* _MSC_VER */
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_