Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ace / SOCK.h
blobba9526d5c50acafb9702a7dfb3d6e0cd7313e346
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file SOCK.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_SOCK_H
12 #define ACE_SOCK_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Addr.h"
22 #include "ace/IPC_SAP.h"
23 #include "ace/OS_NS_stropts.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_SOCK
30 * @brief An abstract class that forms the basis for more specific
31 * classes, such as ACE_SOCK_Acceptor and ACE_SOCK_Stream.
32 * Do not instantiate this class.
34 * This class provides functions that are common to all of the
35 * <ACE_SOCK_*> classes. ACE_SOCK provides the ability to get
36 * and set socket options, get the local and remote addresses,
37 * and open and close a socket handle.
39 class ACE_Export ACE_SOCK : public ACE_IPC_SAP
41 public:
42 /// Wrapper around the @c setsockopt system call.
43 int set_option (int level,
44 int option,
45 void *optval,
46 int optlen) const;
48 /// Wrapper around the @c getsockopt system call.
49 int get_option (int level,
50 int option,
51 void *optval,
52 int *optlen) const;
54 /**
55 * Close the socket.
56 * This method also sets the object's handle value to ACE_INVALID_HANDLE.
58 * @return The result of closing the socket; 0 if the handle value
59 * was already ACE_INVALID_HANDLE.
61 int close ();
63 /// Return the local endpoint address in the referenced ACE_Addr.
64 /// Returns 0 if successful, else -1.
65 int get_local_addr (ACE_Addr &) const;
67 /**
68 * Return the address of the remotely connected peer (if there is
69 * one), in the referenced ACE_Addr. Returns 0 if successful, else
70 * -1.
72 int get_remote_addr (ACE_Addr &) const;
74 /// Dump the state of an object.
75 void dump () const;
77 /// Declare the dynamic allocation hooks.
78 ACE_ALLOC_HOOK_DECLARE;
80 /// Wrapper around the BSD-style @c socket system call (no QoS).
81 int open (int type,
82 int protocol_family,
83 int protocol,
84 int reuse_addr);
86 /// Wrapper around the QoS-enabled @c WSASocket function.
87 int open (int type,
88 int protocol_family,
89 int protocol,
90 ACE_Protocol_Info *protocolinfo,
91 ACE_SOCK_GROUP g,
92 u_long flags,
93 int reuse_addr);
95 protected:
96 /// Constructor with arguments to call the BSD-style @c socket system
97 /// call (no QoS).
98 ACE_SOCK (int type,
99 int protocol_family,
100 int protocol = 0,
101 int reuse_addr = 0);
103 /// Constructor with arguments to call the QoS-enabled @c WSASocket
104 /// function.
105 ACE_SOCK (int type,
106 int protocol_family,
107 int protocol,
108 ACE_Protocol_Info *protocolinfo,
109 ACE_SOCK_GROUP g,
110 u_long flags,
111 int reuse_addr);
113 /// Default constructor is protected to prevent instances of this class
114 /// from being defined.
115 ACE_SOCK ();
117 /// Protected destructor.
119 * Not a virtual destructor. Protected destructor to prevent
120 * operator delete() from being called through a base class ACE_SOCK
121 * pointer/reference.
123 ~ACE_SOCK () = default;
126 ACE_END_VERSIONED_NAMESPACE_DECL
128 #if defined (__ACE_INLINE__)
129 #include "ace/SOCK.inl"
130 #endif /* __ACE_INLINE__ */
132 #include /**/ "ace/post.h"
133 #endif /* ACE_SOCK_H */