summaryrefslogtreecommitdiff
path: root/ace/SOCK.h
blob: 25f2b580cfeed37e364e6bc7234ab65601fd80b5 (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
/* -*- C++ -*- */
// $Id$


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

#if !defined (ACE_SOCK_H)
#define ACE_SOCK_H

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

// The following is necessary since many C++ compilers don't support
// typedef'd types inside of classes used as formal template
// arguments... ;-(.  Luckily, using the C++ preprocessor I can hide
// most of this nastiness!

#if defined (ACE_HAS_TEMPLATE_TYPEDEFS)
#define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor
#define ACE_SOCK_CONNECTOR ACE_SOCK_Connector
#define ACE_SOCK_STREAM ACE_SOCK_Stream
#else /* TEMPLATES are broken (must be a cfront-based compiler...) */
#define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr
#define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr
#define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr
#endif /* ACE_TEMPLATE_TYPEDEFS */

class ACE_Export ACE_SOCK : public ACE_IPC_SAP
  // = TITLE
  //     Defines the member functions for the base class of the
  //     ACE_SOCK abstraction. 
{
public:
  int open (int type, 
	    int protocol_family, 
	    int protocol);
  // Wrapper around the socket() system call.

  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.

  int get_remote_addr (ACE_Addr &) const;
  // Return the address of the remotely connected peer (if there is
  // one).

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

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

protected:
  // = Make this an abstract class.
  ACE_SOCK (void);
  // Default constructor.

  ACE_SOCK (int type, int protocol_family, int protocol = 0);
  // Wrapper around the socket() system call.

#if defined (ACE_WIN32)
  static ACE_SOCK dummy_;
  // Used to ensure we initialize WinSock!
#endif /* ACE_WIN32 */
};

#include "ace/SOCK.i"

#endif /* ACE_SOCK_H */