summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
Diffstat (limited to 'ace')
-rw-r--r--ace/Containers.i9
-rw-r--r--ace/DEV_IO.cpp12
-rw-r--r--ace/DEV_IO.h4
-rw-r--r--ace/DEV_IO.i8
-rw-r--r--ace/FIFO_Send_Msg.cpp2
-rw-r--r--ace/FILE_IO.cpp12
-rw-r--r--ace/FILE_IO.h4
-rw-r--r--ace/FILE_IO.i8
-rw-r--r--ace/LSOCK.cpp4
-rw-r--r--ace/LSOCK_Stream.cpp8
-rw-r--r--ace/LSOCK_Stream.h4
-rw-r--r--ace/OS.h26
-rw-r--r--ace/SOCK_Dgram.cpp22
-rw-r--r--ace/SOCK_Dgram.h6
-rw-r--r--ace/SOCK_Dgram_Bcast.h4
-rw-r--r--ace/SOCK_Dgram_Mcast.cpp117
-rw-r--r--ace/SOCK_Dgram_Mcast.h36
-rw-r--r--ace/SOCK_Dgram_Mcast.i2
-rw-r--r--ace/SOCK_IO.cpp4
-rw-r--r--ace/SOCK_IO.h6
-rw-r--r--ace/SOCK_IO.i6
-rw-r--r--ace/SPIPE_Stream.cpp14
-rw-r--r--ace/SPIPE_Stream.h4
-rw-r--r--ace/SPIPE_Stream.i8
24 files changed, 235 insertions, 95 deletions
diff --git a/ace/Containers.i b/ace/Containers.i
index 562b72a850b..44113495d67 100644
--- a/ace/Containers.i
+++ b/ace/Containers.i
@@ -377,6 +377,8 @@ ACE_Array_Iterator<T>::done (void) const
return this->current_ >= array_.size ();
}
+#if !defined (ACE_LACKS_TEMPLATE_AS_TEMPLATE_PARAMETER)
+
template <class T> ACE_INLINE
ACE_DLList_Node<T>::ACE_DLList_Node (void)
: item_ (0),
@@ -386,8 +388,8 @@ ACE_DLList_Node<T>::ACE_DLList_Node (void)
template <class T> ACE_INLINE
ACE_DLList_Node<T>::ACE_DLList_Node (T *&i,
- ACE_DLList_Node<T> *n,
- ACE_DLList_Node<T> *p)
+ ACE_DLList_Node<T> *n,
+ ACE_DLList_Node<T> *p)
: item_ (i),
next_ (n),
prev_ (p)
@@ -397,7 +399,7 @@ ACE_DLList_Node<T>::ACE_DLList_Node (T *&i,
template <class T> ACE_INLINE
ACE_DLList_Node<T>::~ACE_DLList_Node (void)
{
-};
+}
template <class T> ACE_INLINE void
ACE_DLList<T>::operator= (ACE_DLList<T> &l)
@@ -502,3 +504,4 @@ ACE_DLList_Iterator<T>::dump (void) const
ACE_Double_Linked_List_Iterator< ACE_DLList_Node<T> >::dump ();
}
+#endif /* ! defined (ACE_LACKS_TEMPLATE_AS_TEMPLATE_PARAMETER) */
diff --git a/ace/DEV_IO.cpp b/ace/DEV_IO.cpp
index de00433333d..88ca1cd4ba9 100644
--- a/ace/DEV_IO.cpp
+++ b/ace/DEV_IO.cpp
@@ -62,11 +62,11 @@ ACE_DEV_IO::send (size_t n, ...) const
ACE_TRACE ("ACE_DEV_IO::send");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (ACE_IO_Vector_Base));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -97,11 +97,11 @@ ACE_DEV_IO::recv (size_t n, ...) const
ACE_TRACE ("ACE_DEV_IO::recv");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (iovec));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector_Base[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
diff --git a/ace/DEV_IO.h b/ace/DEV_IO.h
index f5362f6989e..615ec99a27d 100644
--- a/ace/DEV_IO.h
+++ b/ace/DEV_IO.h
@@ -67,10 +67,10 @@ public:
// Send <cntl> and <data> via STREAM pipes.
#endif /* ACE_HAS_STREAM_PIPES */
- ssize_t send (const iovec iov[], size_t n) const;
+ ssize_t send (const ACE_IO_Vector_Base iov[], size_t n) const;
// Send iovecs via <::writev>.
- ssize_t recv (iovec iov[], size_t n) const;
+ ssize_t recv (ACE_IO_Vector_Base iov[], size_t n) const;
// Recv iovecs via <::readv>.
ssize_t send (size_t n, ...) const;
diff --git a/ace/DEV_IO.i b/ace/DEV_IO.i
index 934c1ae3e94..5ae978f04eb 100644
--- a/ace/DEV_IO.i
+++ b/ace/DEV_IO.i
@@ -38,17 +38,17 @@ ACE_DEV_IO::recv (void *buf, size_t n) const
}
ASYS_INLINE ssize_t
-ACE_DEV_IO::send (const iovec iov[], size_t n) const
+ACE_DEV_IO::send (const ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_DEV_IO::send");
- return ACE_OS::writev (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::writev (this->get_handle (), iov, n);
}
ASYS_INLINE ssize_t
-ACE_DEV_IO::recv (iovec iov[], size_t n) const
+ACE_DEV_IO::recv (ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_DEV_IO::recv");
- return ACE_OS::readv (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::readv (this->get_handle (), iov, n);
}
ASYS_INLINE ssize_t
diff --git a/ace/FIFO_Send_Msg.cpp b/ace/FIFO_Send_Msg.cpp
index 163cc564634..b72f732b3ab 100644
--- a/ace/FIFO_Send_Msg.cpp
+++ b/ace/FIFO_Send_Msg.cpp
@@ -31,7 +31,7 @@ ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg)
(strbuf *) &send_msg,
0);
#else
- struct iovec iov[2];
+ struct ACE_IO_Vector_Base iov[2];
iov[0].iov_base = (char *) &send_msg.len;
iov[0].iov_len = sizeof send_msg.len;
diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp
index a13a9f624dd..23dca6e4fe5 100644
--- a/ace/FILE_IO.cpp
+++ b/ace/FILE_IO.cpp
@@ -40,11 +40,11 @@ ACE_FILE_IO::send (size_t n, ...) const
ACE_TRACE ("ACE_FILE_IO::send");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (ACE_IO_Vector_Base));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector_Base[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -75,11 +75,11 @@ ACE_FILE_IO::recv (size_t n, ...) const
ACE_TRACE ("ACE_FILE_IO::recv");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (ACE_IO_Vector_Base));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector_Base[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
diff --git a/ace/FILE_IO.h b/ace/FILE_IO.h
index b7ddcbce2c8..6a089218611 100644
--- a/ace/FILE_IO.h
+++ b/ace/FILE_IO.h
@@ -68,10 +68,10 @@ public:
#endif /* ACE_HAS_STREAM_PIPES */
- ssize_t send (const iovec iov[], size_t n) const;
+ ssize_t send (const ACE_IO_Vector_Base iov[], size_t n) const;
// Send iovecs via <::writev>.
- ssize_t recv (iovec iov[], size_t n) const;
+ ssize_t recv (ACE_IO_Vector_Base iov[], size_t n) const;
// Recv iovecs via <::readv>.
ssize_t send (size_t n, ...) const;
diff --git a/ace/FILE_IO.i b/ace/FILE_IO.i
index 1dd742fef87..f09dd143303 100644
--- a/ace/FILE_IO.i
+++ b/ace/FILE_IO.i
@@ -38,17 +38,17 @@ ACE_FILE_IO::recv (void *buf, size_t n) const
}
ASYS_INLINE ssize_t
-ACE_FILE_IO::send (const iovec iov[], size_t n) const
+ACE_FILE_IO::send (const ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_FILE_IO::send");
- return ACE_OS::writev (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::writev (this->get_handle (), iov, n);
}
ASYS_INLINE ssize_t
-ACE_FILE_IO::recv (iovec iov[], size_t n) const
+ACE_FILE_IO::recv (ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_FILE_IO::recv");
- return ACE_OS::readv (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::readv (this->get_handle (), iov, n);
}
#if defined (ACE_HAS_STREAM_PIPES)
diff --git a/ace/LSOCK.cpp b/ace/LSOCK.cpp
index 002f36296c5..221c80e896e 100644
--- a/ace/LSOCK.cpp
+++ b/ace/LSOCK.cpp
@@ -31,7 +31,7 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const
{
ACE_TRACE ("ACE_LSOCK::send_handle");
unsigned char a[2];
- iovec iov;
+ ACE_IO_Vector_Base iov;
msghdr send_msg;
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
@@ -72,7 +72,7 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, int *len) const
{
ACE_TRACE ("ACE_LSOCK::recv_handle");
unsigned char a[2];
- iovec iov;
+ ACE_IO_Vector_Base iov;
msghdr recv_msg;
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
diff --git a/ace/LSOCK_Stream.cpp b/ace/LSOCK_Stream.cpp
index b8b2d85cff6..d3019b04581 100644
--- a/ace/LSOCK_Stream.cpp
+++ b/ace/LSOCK_Stream.cpp
@@ -60,7 +60,7 @@ ACE_LSOCK_Stream::dump (void) const
// handle.
ssize_t
-ACE_LSOCK_Stream::send_msg (const iovec iov[],
+ACE_LSOCK_Stream::send_msg (const ACE_IO_Vector_Base iov[],
size_t n,
ACE_HANDLE handle)
{
@@ -71,7 +71,7 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[],
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
- send_msg.msg_iov = (iovec *) iov;
+ send_msg.msg_iov = (ACE_IO_Vector_Base *) iov;
send_msg.msg_iovlen = n;
send_msg.msg_name = 0;
send_msg.msg_namelen = 0;
@@ -97,7 +97,7 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[],
// handle.
ssize_t
-ACE_LSOCK_Stream::recv_msg (iovec iov[],
+ACE_LSOCK_Stream::recv_msg (ACE_IO_Vector_Base iov[],
size_t n,
ACE_HANDLE &handle)
{
@@ -108,7 +108,7 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[],
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
- recv_msg.msg_iov = (iovec *) iov;
+ recv_msg.msg_iov = (ACE_IO_Vector_Base *) iov;
recv_msg.msg_iovlen = n;
recv_msg.msg_name = 0;
recv_msg.msg_namelen = 0;
diff --git a/ace/LSOCK_Stream.h b/ace/LSOCK_Stream.h
index c7242098036..504ec91569e 100644
--- a/ace/LSOCK_Stream.h
+++ b/ace/LSOCK_Stream.h
@@ -29,12 +29,12 @@ class ACE_Export ACE_LSOCK_Stream : public ACE_SOCK_Stream, public ACE_LSOCK
// Create a Local ACE_SOCK stream.
public:
// = Send/recv methods.
- ssize_t send_msg (const iovec iov[],
+ ssize_t send_msg (const ACE_IO_Vector_Base iov[],
size_t n,
ACE_HANDLE handle);
// Send iovecs via <::writev>.
- ssize_t recv_msg (iovec iov[],
+ ssize_t recv_msg (ACE_IO_Vector_Base iov[],
size_t n,
ACE_HANDLE &handle);
// Send iovecs via <::writev>.
diff --git a/ace/OS.h b/ace/OS.h
index 85388bbf9a2..89c547d9919 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -4251,6 +4251,18 @@ typedef WSABUF ACE_IO_Vector_Base;
typedef iovec ACE_IO_Vector_Base;
# endif /* ACE_HAS_WINSOCK2 */
+class ACE_Export ACE_IO_Vector : public ACE_IO_Vector_Base
+{
+ // = TITLE
+ // This little adapter class makes it easier to use writev() and
+ // readv() portably on Win32 and UNIX.
+public:
+ ssize_t length (void) const;
+ void length (ssize_t new_length);
+ void *buffer (void) const;
+ void buffer (void *new_buffer);
+};
+
class ACE_Export ACE_OS
{
// = TITLE
@@ -5548,7 +5560,7 @@ extern "C" ssize_t write_timedwait (ACE_HANDLE handle,
size_t n,
struct timespec *timeout);
extern "C" ssize_t readv_timedwait (ACE_HANDLE handle,
- struct iovec *iov,
+ ACE_IO_Vector_Base *iov,
int iovcnt,
struct timespec* timeout);
extern "C" ssize_t writev_timedwait (ACE_HANDLE handle,
@@ -6127,18 +6139,6 @@ private:
# define ACE_INLINE_FOR_GNUC
# endif /* ACE_HAS_GNUC_BROKEN_TEMPLATE_INLINE_FUNCTIONS */
-class ACE_Export ACE_IO_Vector : public ACE_IO_Vector_Base
-{
- // = TITLE
- // This little adapter class makes it easier to use writev() and
- // readv() portably on Win32 and UNIX.
-public:
- ssize_t length (void) const;
- void length (ssize_t new_length);
- void *buffer (void) const;
- void buffer (void *new_buffer);
-};
-
# if defined (ACE_WIN32) && ! defined (ACE_HAS_WINCE)
typedef TRANSMIT_FILE_BUFFERS ACE_TRANSMIT_FILE_BUFFERS;
typedef LPTRANSMIT_FILE_BUFFERS ACE_LPTRANSMIT_FILE_BUFFERS;
diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp
index 04634dcca13..d0589721476 100644
--- a/ace/SOCK_Dgram.cpp
+++ b/ace/SOCK_Dgram.cpp
@@ -26,7 +26,7 @@ ACE_SOCK_Dgram::dump (void) const
// returns the number of bytes read.
ssize_t
-ACE_SOCK_Dgram::recv (iovec *io_vec,
+ACE_SOCK_Dgram::recv (ACE_IO_Vector_Base *io_vec,
ACE_Addr &addr,
int flags) const
{
@@ -121,11 +121,11 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local,
}
#if defined (ACE_HAS_MSG)
-// Send an iovec of size N to ADDR as a datagram (connectionless
+// Send an ACE_IO_Vector_Base of size N to ADDR as a datagram (connectionless
// version).
ssize_t
-ACE_SOCK_Dgram::send (const iovec iov[],
+ACE_SOCK_Dgram::send (const ACE_IO_Vector_Base iov[],
size_t n,
const ACE_Addr &addr,
int flags) const
@@ -133,7 +133,7 @@ ACE_SOCK_Dgram::send (const iovec iov[],
ACE_TRACE ("ACE_SOCK_Dgram::send");
msghdr send_msg;
- send_msg.msg_iov = (iovec *) iov;
+ send_msg.msg_iov = (ACE_IO_Vector_Base *) iov;
send_msg.msg_iovlen = n;
#if defined (ACE_HAS_SOCKADDR_MSG_NAME)
send_msg.msg_name = (struct sockaddr *) addr.get_addr ();
@@ -154,11 +154,11 @@ ACE_SOCK_Dgram::send (const iovec iov[],
return ACE_OS::sendmsg (this->get_handle (), &send_msg, flags);
}
-// Recv an iovec of size N to ADDR as a datagram (connectionless
+// Recv an ACE_IO_Vector_Base of size N to ADDR as a datagram (connectionless
// version).
ssize_t
-ACE_SOCK_Dgram::recv (iovec iov[],
+ACE_SOCK_Dgram::recv (ACE_IO_Vector_Base iov[],
size_t n,
ACE_Addr &addr,
int flags) const
@@ -166,7 +166,7 @@ ACE_SOCK_Dgram::recv (iovec iov[],
ACE_TRACE ("ACE_SOCK_Dgram::recv");
msghdr recv_msg;
- recv_msg.msg_iov = (iovec *) iov;
+ recv_msg.msg_iov = (ACE_IO_Vector_Base *) iov;
recv_msg.msg_iovlen = n;
#if defined (ACE_HAS_SOCKADDR_MSG_NAME)
recv_msg.msg_name = (struct sockaddr *) addr.get_addr ();
@@ -191,11 +191,11 @@ ACE_SOCK_Dgram::recv (iovec iov[],
#else /* ACE_HAS_MSG */
-// Send an iovec of size N to ADDR as a datagram (connectionless
+// Send an ACE_IO_Vector_Base of size N to ADDR as a datagram (connectionless
// version).
ssize_t
-ACE_SOCK_Dgram::send (const iovec iov[],
+ACE_SOCK_Dgram::send (const ACE_IO_Vector_Base iov[],
size_t n,
const ACE_Addr &addr,
int flags) const
@@ -239,11 +239,11 @@ ACE_SOCK_Dgram::send (const iovec iov[],
return result;
}
-// Recv an iovec of size N to ADDR as a datagram (connectionless
+// Recv an ACE_IO_Vector_Base of size N to ADDR as a datagram (connectionless
// version).
ssize_t
-ACE_SOCK_Dgram::recv (iovec iov[],
+ACE_SOCK_Dgram::recv (ACE_IO_Vector_Base iov[],
size_t n,
ACE_Addr &addr,
int flags) const
diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h
index 4b4313c11bc..8a4d5cbf0fa 100644
--- a/ace/SOCK_Dgram.h
+++ b/ace/SOCK_Dgram.h
@@ -59,7 +59,7 @@ public:
// Receive an <n> byte <buf> from the datagram socket (uses
// recvfrom(3)).
- ssize_t recv (iovec *io_vec,
+ ssize_t recv (ACE_IO_Vector_Base *io_vec,
ACE_Addr &addr,
int flags = 0) const;
// Allows a client to read from a socket without having to provide a
@@ -69,14 +69,14 @@ public:
// deleting the member in the <iov_base> field of <io_vec> using the
// ``delete []'' syntax.
- ssize_t send (const iovec iov[],
+ ssize_t send (const ACE_IO_Vector_Base iov[],
size_t n,
const ACE_Addr &addr,
int flags = 0) const;
// Send an <iovec> of size <n> to the datagram socket (uses
// sendmsg(3)).
- ssize_t recv (iovec iov[],
+ ssize_t recv (ACE_IO_Vector_Base iov[],
size_t n,
ACE_Addr &addr,
int flags = 0) const;
diff --git a/ace/SOCK_Dgram_Bcast.h b/ace/SOCK_Dgram_Bcast.h
index 64e134b21c9..f03ea5d822b 100644
--- a/ace/SOCK_Dgram_Bcast.h
+++ b/ace/SOCK_Dgram_Bcast.h
@@ -71,7 +71,7 @@ public:
// Broadcast the datagram to every interface. Returns the average
// number of bytes sent.
- ssize_t send (const iovec iov[],
+ ssize_t send (const ACE_IO_Vector_Base iov[],
size_t n,
u_short portnum,
int flags = 0) const;
@@ -85,7 +85,7 @@ public:
// Broadcast an N byte datagram to ADDR (note that addr must be
// preassigned to the broadcast address of the subnet...).
- ssize_t send (const iovec iov[],
+ ssize_t send (const ACE_IO_Vector_Base iov[],
size_t n,
const ACE_Addr &addr,
int flags = 0) const;
diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp
index 522131ecaa3..b4a4fa71a5a 100644
--- a/ace/SOCK_Dgram_Mcast.cpp
+++ b/ace/SOCK_Dgram_Mcast.cpp
@@ -153,6 +153,96 @@ ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
}
int
+ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr,
+#if defined (ACE_PSOS)
+ // pSOS supports numbers, not
+ // names for network interfaces
+ long net_if,
+#else
+ const ASYS_TCHAR *net_if,
+#endif /* defined (ACE_PSOS) */
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe");
+
+#if defined (ACE_WIN32)
+ // Windows NT's winsock has trouble with multicast subscribes in the presence
+ // of multiple network interfaces when the IP address is given as INADDR_ANY.
+ // It will pick the first interface and only accept mcast there. So, to work
+ // around this, cycle through all of the interfaces known and subscribe to
+ // all the non-loopback ones.
+ // Note that this only needs to be done on NT, but there's no way to tell
+ // at this point if the code will be running on NT - only if it is compiled
+ // for NT-only or for NT/95, and that doesn't really help us. It doesn't
+ // hurt to do this on Win95, it's just a little slower than it normally
+ // would be.
+ //
+ // NOTE - get_ip_interfaces doesn't always get all of the interfaces. In
+ // particular, it may not get a PPP interface. This is a limitation of the
+ // way get_ip_interfaces works with MSVC. The reliable way of getting the
+ // interface list is available only with MSVC 5.
+
+ if (net_if == 0)
+ {
+ ACE_INET_Addr *if_addrs = 0;
+ size_t if_cnt, nr_subscribed;
+
+ if (ACE::get_ip_interfaces(if_cnt, if_addrs) != 0)
+ return -1;
+
+ nr_subscribed = 0;
+
+ if (if_cnt < 2)
+ {
+ if (this->unsubscribe (mcast_addr,
+ reuse_addr,
+ ASYS_WIDE_STRING ("0.0.0.0"),
+ protocol_family,
+ protocol) == 0)
+ ++nr_subscribed;
+ }
+ else
+ while (if_cnt > 0)
+ {
+ --if_cnt; // Convert to 0-based for indexing, next loop check
+ if (if_addrs[if_cnt].get_ip_address() == INADDR_LOOPBACK)
+ continue;
+ if (this->unsubscribe (mcast_addr,
+ reuse_addr,
+ ASYS_WIDE_STRING (if_addrs[if_cnt].get_host_addr()),
+ protocol_family,
+ protocol) == 0)
+ ++nr_subscribed;
+ }
+
+ delete [] if_addrs;
+
+ if (nr_subscribed == 0)
+ {
+ errno = ENODEV;
+ return -1;
+ }
+ return 0;
+ }
+ // else do it like everyone else...
+#endif /* ACE_WIN32 */
+
+ // Create multicast request.
+ if (this->make_multicast_address (mcast_addr, net_if) == -1)
+ return -1;
+
+ // Tell network device driver to read datagrams with a
+ // multicast_address address.
+ else if (this->ACE_SOCK::set_option (IPPROTO_IP,
+ IP_DROP_MEMBERSHIP,
+ &multicast_address_,
+ sizeof multicast_address_) == -1)
+ return -1;
+ return 0;
+}
+
+int
ACE_SOCK_Dgram_Mcast::unsubscribe (void)
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe");
@@ -175,6 +265,23 @@ ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr,
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_address");
+ return this->make_multicast_address_i (mcast_addr,
+ this->multicast_address_,
+ net_if );
+}
+
+int
+ACE_SOCK_Dgram_Mcast::make_multicast_address_i (const ACE_INET_Addr &mcast_addr,
+ ip_mreq &multicast_address ,
+#if defined (ACE_PSOS)
+ // pSOS supports numbers, not
+ // names for network interfaces
+ long net_if
+#else
+ const ASYS_TCHAR *net_if
+#endif /* defined (ACE_PSOS) */
+ )
+{
if (net_if != 0)
{
#if !defined (ACE_WIN32)
@@ -193,24 +300,24 @@ ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr,
struct sockaddr_in *socket_address;
socket_address = ACE_reinterpret_cast(sockaddr_in *,
&if_address.ifr_addr);
- multicast_address_.imr_interface.s_addr = socket_address->sin_addr.s_addr;
+ multicast_address.imr_interface.s_addr = socket_address->sin_addr.s_addr;
#else
// This port number is not necessary, just convenient
ACE_INET_Addr interface_addr;
if (interface_addr.set (mcast_addr.get_port_number (),
net_if) == -1)
return -1;
- multicast_address_.imr_interface.s_addr =
+ multicast_address.imr_interface.s_addr =
htonl (interface_addr.get_ip_address ());
#endif /* ACE_WIN32 */
}
else
- multicast_address_.imr_interface.s_addr = INADDR_ANY;
+ multicast_address.imr_interface.s_addr = INADDR_ANY;
#if defined (ACE_PSOS) && !defined (ACE_PSOS_TM)
- multicast_address_.imr_mcastaddr.s_addr = htonl (mcast_addr.get_ip_address ());
+ multicast_address.imr_mcastaddr.s_addr = htonl (mcast_addr.get_ip_address ());
#else
- multicast_address_.imr_multiaddr.s_addr = htonl (mcast_addr.get_ip_address ());
+ multicast_address.imr_multiaddr.s_addr = htonl (mcast_addr.get_ip_address ());
#endif /* defined (ACE_PSOS) */
return 0;
}
diff --git a/ace/SOCK_Dgram_Mcast.h b/ace/SOCK_Dgram_Mcast.h
index c2d68ef5976..c2f132d6eea 100644
--- a/ace/SOCK_Dgram_Mcast.h
+++ b/ace/SOCK_Dgram_Mcast.h
@@ -61,6 +61,22 @@ public:
// subscribe uses the default mcast interface.
// Returns: -1 on error, else 0.
+ int unsubscribe (const ACE_INET_Addr &mcast_addr,
+#if defined (ACE_PSOS)
+ // pSOS supports numbers, not names for network interfaces
+ long net_if = 0,
+#else
+ const ASYS_TCHAR *net_if = 0,
+#endif /* defined (ACE_PSOS) */
+ int protocol_family = PF_INET,
+ int protocol = 0);
+ // Leave a multicast group.
+ //
+ // Interface is hardware specific. use netstat -i to find whether
+ // your interface is, say, le0 or something else. If net_if == 0,
+ // subscribe uses the default mcast interface.
+ // Returns: -1 on error, else 0.
+
int unsubscribe (void);
// Unsubscribe from a multicast group. Returns 0 on success, -1 on
// failure.
@@ -69,7 +85,9 @@ public:
ssize_t send (const void *buf, size_t n, int flags = 0) const;
// Send <n> bytes in <buf>.
- ssize_t send (const iovec iov[], size_t n, int flags = 0) const;
+ ssize_t send (const ACE_IO_Vector_Base iov[],
+ size_t n,
+ int flags = 0) const;
// Send <n> <iovecs>.
// = Options.
@@ -97,7 +115,7 @@ private:
size_t n,
const ACE_Addr &addr,
int flags = 0) const;
- ssize_t send (const iovec iov[],
+ ssize_t send (const ACE_IO_Vector_Base iov[],
size_t n,
const ACE_Addr &addr,
int flags = 0) const;
@@ -111,12 +129,24 @@ private:
const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")
#endif /* defined (ACE_PSOS) */
);
+ // Initialize the <multicast_addres_ field>
+
+ int make_multicast_address_i (const ACE_INET_Addr &mcast_addr,
+ ip_mreq& multicast_address,
+#if defined (ACE_PSOS)
+ // pSOS supports numbers, not
+ // names for network interfaces
+ long net_if = 0
+#else
+ const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")
+#endif /* defined (ACE_PSOS) */
+ );
// Initialize a multicast address.
ACE_INET_Addr mcast_addr_;
// Multicast group address.
- struct ip_mreq multicast_address_;
+ ip_mreq multicast_address_;
// IP address.
};
diff --git a/ace/SOCK_Dgram_Mcast.i b/ace/SOCK_Dgram_Mcast.i
index 196171208b8..ca3eb0cbc4d 100644
--- a/ace/SOCK_Dgram_Mcast.i
+++ b/ace/SOCK_Dgram_Mcast.i
@@ -27,7 +27,7 @@ ACE_SOCK_Dgram_Mcast::send (const void *buf,
}
ASYS_INLINE ssize_t
-ACE_SOCK_Dgram_Mcast::send (const iovec iov[],
+ACE_SOCK_Dgram_Mcast::send (const ACE_IO_Vector_Base iov[],
size_t n, int flags) const
{
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::send");
diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp
index 1b54cc31527..971ee469676 100644
--- a/ace/SOCK_IO.cpp
+++ b/ace/SOCK_IO.cpp
@@ -24,7 +24,7 @@ ACE_SOCK_IO::dump (void) const
// returns the number of bytes read.
ssize_t
-ACE_SOCK_IO::recv (iovec *io_vec)
+ACE_SOCK_IO::recv (ACE_IO_Vector_Base *io_vec)
{
#if defined (FIONREAD)
u_long inlen;
@@ -107,7 +107,7 @@ ACE_SOCK_IO::send (size_t n, ...) const
}
// This is basically an interface to ACE_OS::readv, that doesn't use
-// the struct iovec explicitly. The ... can be passed as an arbitrary
+// the struct ACE_IO_Vector_Base explicitly. The ... can be passed as an arbitrary
// number of (char *ptr, int len) tuples. However, the count N is the
// *total* number of trailing arguments, *not* a couple of the number
// of tuple pairs!
diff --git a/ace/SOCK_IO.h b/ace/SOCK_IO.h
index ce5a6ac583c..9e1e909dd71 100644
--- a/ace/SOCK_IO.h
+++ b/ace/SOCK_IO.h
@@ -55,7 +55,7 @@ public:
// Recv an <n> byte buffer from the connected socket (uses
// <read(2)>).
- ssize_t send (const iovec iov[],
+ ssize_t send (const ACE_IO_Vector_Base iov[],
size_t n) const;
// Send a vector of an <n> byte messages to the connected socket.
@@ -63,7 +63,7 @@ public:
size_t n) const;
// Send a vector of an <n> byte messages to the connected socket.
- ssize_t recv (iovec iov[],
+ ssize_t recv (ACE_IO_Vector_Base iov[],
size_t n) const;
// Recv a vector of an <n> byte messages to the connected socket.
@@ -123,7 +123,7 @@ public:
ACE_OVERLAPPED *overlapped) const;
// Recv <n> bytes via Win32 ReadFile using overlapped I/O.
- ssize_t recv (iovec *io_vec);
+ ssize_t recv (ACE_IO_Vector_Base *io_vec);
// Allows a client to read from a socket without having to provide a
// buffer to read. This method determines how much data is in the
// socket, allocates a buffer of this size, reads in the data, and
diff --git a/ace/SOCK_IO.i b/ace/SOCK_IO.i
index c6ded82096b..c9a9cab5a7b 100644
--- a/ace/SOCK_IO.i
+++ b/ace/SOCK_IO.i
@@ -62,10 +62,10 @@ ACE_SOCK_IO::recv (void *buf, size_t n) const
// Send a vector of n byte messages to the connected socket.
ASYS_INLINE ssize_t
-ACE_SOCK_IO::send (const iovec iov[], size_t n) const
+ACE_SOCK_IO::send (const ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_SOCK_IO::send");
- return ACE_OS::writev (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::writev (this->get_handle (), iov, n);
}
ASYS_INLINE ssize_t
@@ -78,7 +78,7 @@ ACE_SOCK_IO::send (const ACE_IO_Vector iov[], size_t n) const
// Recv an n byte message from the connected socket.
ASYS_INLINE ssize_t
-ACE_SOCK_IO::recv (iovec iov[], size_t n) const
+ACE_SOCK_IO::recv (ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_SOCK_IO::recv");
return ACE_OS::readv (this->get_handle (), iov, n);
diff --git a/ace/SPIPE_Stream.cpp b/ace/SPIPE_Stream.cpp
index 29a5433dd3d..1430fa8dfdb 100644
--- a/ace/SPIPE_Stream.cpp
+++ b/ace/SPIPE_Stream.cpp
@@ -36,11 +36,11 @@ ACE_SPIPE_Stream::send (size_t n, ...) const
// ACE_TRACE ("ACE_SPIPE_Stream::send");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (ACE_IO_Vector_Base));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector_Base[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -60,7 +60,7 @@ ACE_SPIPE_Stream::send (size_t n, ...) const
}
// This is basically an interface to ACE_OS::readv, that doesn't use
-// the struct iovec explicitly. The ... can be passed as an arbitrary
+// the struct ACE_IO_Vector_Base explicitly. The ... can be passed as an arbitrary
// number of (char *ptr, int len) tuples. However, the count N is the
// *total* number of trailing arguments, *not* a couple of the number
// of tuple pairs!
@@ -71,11 +71,11 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const
ACE_TRACE ("ACE_SPIPE_Stream::recv");
va_list argp;
size_t total_tuples = n / 2;
- iovec *iovp;
+ ACE_IO_Vector_Base *iovp;
#if defined (ACE_HAS_ALLOCA)
- iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
+ iovp = (ACE_IO_Vector_Base *) alloca (total_tuples * sizeof (ACE_IO_Vector_Base));
#else
- ACE_NEW_RETURN (iovp, iovec[total_tuples], -1);
+ ACE_NEW_RETURN (iovp, ACE_IO_Vector_Base[total_tuples], -1);
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
diff --git a/ace/SPIPE_Stream.h b/ace/SPIPE_Stream.h
index 60adbc8fede..b1472b3e3a8 100644
--- a/ace/SPIPE_Stream.h
+++ b/ace/SPIPE_Stream.h
@@ -78,10 +78,10 @@ public:
int *flags) const;
// Recv bytes via STREAM pipes using "band" mode.
- ssize_t send (const iovec iov[], size_t n) const;
+ ssize_t send (const ACE_IO_Vector_Base iov[], size_t n) const;
// Send iovecs via <::writev>.
- ssize_t recv (iovec iov[], size_t n) const;
+ ssize_t recv (ACE_IO_Vector_Base iov[], size_t n) const;
// Recv iovecs via <::readv>.
ssize_t send (size_t n, ...) const;
diff --git a/ace/SPIPE_Stream.i b/ace/SPIPE_Stream.i
index 6f3e6310698..6ebd71d6457 100644
--- a/ace/SPIPE_Stream.i
+++ b/ace/SPIPE_Stream.i
@@ -76,17 +76,17 @@ ACE_SPIPE_Stream::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *fl
}
ASYS_INLINE ssize_t
-ACE_SPIPE_Stream::send (const iovec iov[], size_t n) const
+ACE_SPIPE_Stream::send (const ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_SPIPE_Stream::send");
- return ACE_OS::writev (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::writev (this->get_handle (), iov, n);
}
ASYS_INLINE ssize_t
-ACE_SPIPE_Stream::recv (iovec iov[], size_t n) const
+ACE_SPIPE_Stream::recv (ACE_IO_Vector_Base iov[], size_t n) const
{
ACE_TRACE ("ACE_SPIPE_Stream::recv");
- return ACE_OS::readv (this->get_handle (), (iovec *) iov, n);
+ return ACE_OS::readv (this->get_handle (), iov, n);
}
// This routine sends an open file descriptor to this socket.