diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-02-15 00:35:15 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-02-15 00:35:15 +0000 |
commit | aa16abffbacee596fba00b27fa9ebae3a7c5e0c0 (patch) | |
tree | bab645777ccfa5bbd06df58c97ae5d5d8c9c96a0 /ace/SOCK_Dgram_Mcast.cpp | |
parent | 01dd3c37faab3c9eff5b3b32080c43aa31cbbc39 (diff) | |
download | ATCD-aa16abffbacee596fba00b27fa9ebae3a7c5e0c0.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace/SOCK_Dgram_Mcast.cpp')
-rw-r--r-- | ace/SOCK_Dgram_Mcast.cpp | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp index 756d9ca5183..ffb93ea9b92 100644 --- a/ace/SOCK_Dgram_Mcast.cpp +++ b/ace/SOCK_Dgram_Mcast.cpp @@ -28,47 +28,53 @@ ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr, int protocol) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe"); - // make a local copy of address to use in sends + + // Make a local copy of address to use in sends. this->mcast_addr_.set (mcast_addr); - if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, + // Only perform the open() initialization if we haven't been opened + // previously. + if (this->get_handle () == ACE_INVALID_HANDLE) + { + if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, protocol, reuse_addr) == -1) - return -1; - - // Create multicast request. - if (this->make_multicast_address (this->mcast_addr_, net_if) == -1) - return -1; - - int one = 1; - if (reuse_addr - && this->ACE_SOCK::set_option (SOL_SOCKET, - SO_REUSEADDR, - &one, - sizeof one) == -1) - return -1; + return -1; + + int one = 1; + if (reuse_addr + && this->ACE_SOCK::set_option (SOL_SOCKET, + SO_REUSEADDR, + &one, + sizeof one) == -1) + return -1; #if defined (SO_REUSEPORT) - if (this->ACE_SOCK::set_option (SOL_SOCKET, - SO_REUSEPORT, - &one, - sizeof one) == -1) - return -1; + if (this->ACE_SOCK::set_option (SOL_SOCKET, + SO_REUSEPORT, + &one, + sizeof one) == -1) + return -1; #endif /* SO_REUSEPORT */ - // Create an address to bind the socket to. + // Create an address to bind the socket to. - ACE_INET_Addr local; + ACE_INET_Addr local; - if (local.set (this->mcast_addr_.get_port_number ()) == -1) - return -1; - else if (ACE_SOCK_Dgram::shared_open (local, protocol_family) == -1) + if (local.set (this->mcast_addr_.get_port_number ()) == -1) + return -1; + else if (ACE_SOCK_Dgram::shared_open (local, protocol_family) == -1) + return -1; + } + + // Create multicast request. + if (this->make_multicast_address (this->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_ADD_MEMBERSHIP, - &multicast_address_, - sizeof multicast_address_) == -1) + IP_ADD_MEMBERSHIP, + &multicast_address_, + sizeof multicast_address_) == -1) return -1; return 0; } |