3 //==========================================================================
7 * @author Priyanka Gontla <pgontla@ece.uci.edu>
8 * @author Based on code that existed formerly in ACE.h.
10 //==========================================================================
12 #ifndef ACE_SOCK_CONNECT_H
13 #define ACE_SOCK_CONNECT_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Basic_Types.h"
24 #include "ace/os_include/netinet/os_in.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 // Forward Declarations
33 // = Socket connection establishment calls.
35 /// Bind a new unused port to @a handle.
36 extern ACE_Export
int bind_port (ACE_HANDLE handle
,
37 ACE_UINT32 ip_addr
= INADDR_ANY
,
38 int address_family
= AF_UNSPEC
);
41 * Get our broadcast address based on our @a host_addr. If
42 * @a hostname is non-0 we'll use it to determine our IP address. If
43 * @a handle is not ACE_INVALID_HANDLE then we'll use this to
44 * determine our broadcast address, otherwise we'll have to create a
45 * socket internally (and free it). Returns -1 on failure and 0 on
48 extern ACE_Export
int get_bcast_addr (
49 ACE_UINT32
&bcast_addr
,
50 const ACE_TCHAR
*hostname
= 0,
51 ACE_UINT32 host_addr
= 0,
52 ACE_HANDLE handle
= ACE_INVALID_HANDLE
);
54 /// Get fully qualified host/domain name.
55 extern ACE_Export
int get_fqdn (ACE_INET_Addr
const & addr
,
60 * Return count and array of all configured IP interfaces on this
61 * host, rc = 0 on success (count == number of interfaces else -1).
62 * Caller is responsible for calling delete [] on @a addr_array.
64 extern ACE_Export
int get_ip_interfaces (size_t &count
,
65 ACE_INET_Addr
*&addr_array
);
68 * Helper routine for get_ip_interfaces, differs by UNIX platform so
69 * put into own subroutine. perform some ioctls to retrieve ifconf
70 * list of ifreq structs.
72 extern ACE_Export
int count_interfaces (ACE_HANDLE handle
,
75 /// Routine to return a handle from which @c ioctl requests can be
76 /// made. Caller must close the handle.
77 extern ACE_Export ACE_HANDLE
get_handle ();
79 /// Returns @c true if IPv4 is enabled on the current host; @c false
82 * This is an execution-time check. If ACE has not been compiled
83 * with @c ACE_HAS_IPV6, it always returns @c true. This function
84 * tries to create a @c PF_INET socket, returning @c true if it
85 * succeeds, and @c false if it fails. Caches the result so it only
88 extern ACE_Export
bool ipv4_enabled ();
91 * Returns 1 if IPv6 is enabled on the current host; 0 if not.
92 * This is an execution-time check. If ACE has not been compiled
93 * with ACE_HAS_IPV6, it always returns 0. If ACE_HAS_IPV6 is
94 * enabled, this function tries to create a PF_INET6 socket,
95 * returning 1 if it succeeds, and 0 if it fails. Caches the result
96 * so it only gets checked once.
98 extern ACE_Export
int ipv6_enabled ();
101 ACE_END_VERSIONED_NAMESPACE_DECL
103 #include /**/ "ace/post.h"
105 #endif /* ACE_SOCK_CONNECT_H */