summaryrefslogtreecommitdiff
path: root/ace/SOCK.h
blob: 9ce912d095cb63a72dd8b2ef46717d6db8d0db18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* -*- C++ -*- */
// $Id$

//============================================================================
//
// = LIBRARY
//    ace
//
// = FILENAME
//    SOCK.h
//
// = AUTHOR
//    Doug Schmidt
//
//============================================================================

#ifndef ACE_SOCK_H
#define ACE_SOCK_H

#include "ace/ACE.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Addr.h"
#include "ace/IPC_SAP.h"
#include "ace/QoS_Session.h"

class ACE_Export ACE_SOCK : public ACE_IPC_SAP
{
  // = TITLE
  //     An abstract class that forms the basis for more specific
  //     classes, such as <ACE_SOCK_Acceptor> and <ACE_SOCK_Stream>.
  //     Do not instantiate this class.
  //
  // = DESCRIPTION
  //    This class provides functions that are common to all of the
  //    <ACE_SOCK_*> classes. <ACE_SOCK> provides the ability to get
  //    and set socket options, get the local and remote addresses,
  //    and close the socket.
public:
  ~ACE_SOCK (void);
  // Default ctor/dtor.

  int set_option (int level,
                  int option,
                  void *optval,
                  int optlen) const;
  // Wrapper around the <setsockopt> system call.

  int get_option (int level,
                  int option,
                  void *optval,
                  int *optlen) const;
  // Wrapper around the <getsockopt> system call.

  int close (void);
  // Close down the socket.

  int get_local_addr (ACE_Addr &) const;
  // Return the local endpoint address in the referenced <ACE_Addr>.
  // Returns 0 if successful, else -1.

  int get_remote_addr (ACE_Addr &) const;
  // Return the address of the remotely connected peer (if there is
  // one), in the referenced <ACE_Addr>. Returns 0 if successful, else
  // -1.

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

  int open (int type,
            int protocol_family,
            int protocol,
            int reuse_addr);
  // Wrapper around the BSD-style <socket> system call (no QoS).

  int open (int type,
            int protocol_family,
            int protocol,
            ACE_Protocol_Info *protocolinfo,
            ACE_SOCK_GROUP g,
            u_long flags,
            int reuse_addr);
  // Wrapper around the QoS-enabled <WSASocket> function.

  int join_qos_session (ACE_QoS_Session *qos_session);
  // Join the given QoS session. A socket can join multiple QoS sessions. 
  // This call adds the given QoS session to the list of QoS sessions 
  // that the socket has already joined.

  typedef ACE_Unbounded_Set <ACE_QoS_Session *> ACE_QOS_SESSION_SET;

  ACE_QOS_SESSION_SET qos_session_set (void);
  // Get the QoS session set.
  
protected:
  ACE_SOCK (int type,
            int protocol_family,
            int protocol = 0,
            int reuse_addr = 0);
  // Constructor with arguments to call the BSD-style <socket> system
  // call (no QoS).

  ACE_SOCK (int type,
            int protocol_family,
            int protocol,
            ACE_Protocol_Info *protocolinfo,
            ACE_SOCK_GROUP g,
             u_long flags,
            int reuse_addr);
  // Constructor with arguments to call the QoS-enabled <WSASocket>
  // function.

  ACE_SOCK (void);
  // Default constructor is private to prevent instances of this class
  // from being defined.

  ACE_QOS_SESSION_SET qos_session_set_;
  // Set of QoS sessions that this socket has joined.

};

#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
#include "ace/SOCK.i"
#endif /* ACE_LACKS_INLINE_FUNCTIONS */

#endif /* ACE_SOCK_H */