ASN1C C/C++ Common Runtime  ASN1C v7.5.x
OSRTSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1997-2021 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
24 
29 #ifndef _OSRTSOCKET_H_
30 #define _OSRTSOCKET_H_
31 
32 #ifndef _OS_NOSOCKET
33 
34 /* Disable MS VC++ Level 4 warning about unreferenced inline functions */
35 #ifdef _MSC_VER
36 #pragma warning(disable: 4514)
37 #endif /* _MSC_VER */
38 
39 #include "rtxsrc/rtxSocket.h"
40 
50 class EXTRTCLASS OSRTSocket {
51  protected:
53  int mInitStatus;
54  int mStatus;
56  OSBOOL mOwner;
57 
58  inline OSBOOL isInitialized () { return mInitStatus == 0; }
59 
60  public:
68  EXTRTMETHOD OSRTSocket ();
69 
80  EXTRTMETHOD OSRTSocket
81  (OSRTSOCKET socket, OSBOOL ownership = FALSE, int retryCount = 1);
82 
87  EXTRTMETHOD OSRTSocket (const OSRTSocket& socket);
88 
93  EXTRTMETHOD ~OSRTSocket ();
94 
111  EXTRTMETHOD OSRTSocket* accept (OSIPADDR* destIP = 0, int *port = 0);
112 
123  EXTRTMETHOD static const char* addrToString
124  (OSIPADDR ipAddr, char* pAddrStr, size_t bufsize);
125 
140  EXTRTMETHOD int bind (OSIPADDR addr, int port);
141 
154  EXTRTMETHOD int bindUrl (const char* url);
155 
172  EXTRTMETHOD int bind (const char* pAddrStr, int port);
173 
187  inline int bind (int port) {
188  return bind (OSIPADDR_ANY, port);
189  }
190 
202  EXTRTMETHOD int blockingRead (OSOCTET* pbuf, size_t readBytes);
203 
212  EXTRTMETHOD int close ();
213 
229  EXTRTMETHOD int connect (const char* host, int port);
230 
246  EXTRTMETHOD int connectTimed (const char* host, int port, int nsecs);
247 
259  EXTRTMETHOD int connectUrl (const char* url);
260 
267  OSBOOL getOwnership () { return mOwner; }
268 
274  OSRTSOCKET getSocket () const { return mSocket; }
275 
283  inline int getStatus () { return mStatus; }
284 
296  EXTRTMETHOD int listen (int maxConnections);
297 
311  EXTRTMETHOD int recv (OSOCTET* pbuf, size_t bufsize);
312 
325  EXTRTMETHOD int send (const OSOCTET* pdata, size_t size);
326 
336  inline void setOwnership (OSBOOL ownership) { mOwner = ownership; }
337 
345  inline void setRetryCount (int value) { mRetryCount = value; }
346 
358  EXTRTMETHOD static OSIPADDR stringToAddr (const char* pAddrStr);
359 } ;
360 
363 #endif /* _OS_NOSOCKET */
364 
365 #endif //_OSRTSOCKET_H_
OSBOOL mOwner
indicates this class owns the socket
Definition: OSRTSocket.h:56
OSBOOL getOwnership()
Definition: OSRTSocket.h:267
int OSRTSOCKET
Definition: rtxSocket.h:65
void setRetryCount(int value)
Definition: OSRTSocket.h:345
void setOwnership(OSBOOL ownership)
Definition: OSRTSocket.h:336
OSRTSOCKET mSocket
handle of the socket
Definition: OSRTSocket.h:52
int getStatus()
Definition: OSRTSocket.h:283
int mRetryCount
number of time to retry socker connect
Definition: OSRTSocket.h:55
Definition: OSRTSocket.h:50
unsigned long OSIPADDR
Definition: rtxSocket.h:80
OSRTSOCKET getSocket() const
Definition: OSRTSocket.h:274
int bind(int port)
Definition: OSRTSocket.h:187