TAO_AV_UDP_Connection_Setup Class Reference

This class is a helper for the TAO_AV_UDP_Acceptor and TAO_AV_UDP_Connector. It basically just reduces duplicate code. It takes the address of the peer in the connection, whether or not it is a multicast connection, and whether it is a connector or acceptor; and creates the local address and flow handler associated with the connection. More...

#include <UDP.h>

List of all members.

Public Types

enum  ConnectionType { CONNECTOR, ACCEPTOR }
 Indicates whether this setup is for a Connector or an Acceptor. More...


Static Public Member Functions

int setup (TAO_AV_Flow_Handler *&flow_handler, ACE_INET_Addr *inet_addr, ACE_INET_Addr *&local_addr, int is_multicast, ConnectionType ct)


Detailed Description

This class is a helper for the TAO_AV_UDP_Acceptor and TAO_AV_UDP_Connector. It basically just reduces duplicate code. It takes the address of the peer in the connection, whether or not it is a multicast connection, and whether it is a connector or acceptor; and creates the local address and flow handler associated with the connection.

Definition at line 216 of file UDP.h.


Member Enumeration Documentation

enum TAO_AV_UDP_Connection_Setup::ConnectionType
 

Indicates whether this setup is for a Connector or an Acceptor.

Enumeration values:
CONNECTOR 
ACCEPTOR 

Definition at line 220 of file UDP.h.

00220 {CONNECTOR, ACCEPTOR};


Member Function Documentation

int TAO_AV_UDP_Connection_Setup::setup TAO_AV_Flow_Handler *&  flow_handler,
ACE_INET_Addr inet_addr,
ACE_INET_Addr *&  local_addr,
int  is_multicast,
ConnectionType  ct
[static]
 

Definition at line 787 of file UDP.cpp.

References ACCEPTOR, ACE_DEBUG, ACE_DEFAULT_MAX_SOCKET_BUFSIZ, ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_INET_Addr::addr_to_string(), CONNECTOR, ENOTSUP, ACE_INET_Addr::get_host_name(), TAO_AV_UDP_MCast_Flow_Handler::get_mcast_socket(), ACE_INET_Addr::get_port_number(), IP_MULTICAST_LOOP, LM_DEBUG, LM_ERROR, TAO_AV_UDP_Flow_Handler::open(), ACE_INET_Addr::set(), ACE_SOCK_Dgram_Mcast::subscribe(), and TAO_debug_level.

Referenced by TAO_AV_UDP_Connector::connect(), and TAO_AV_UDP_Acceptor::open_i().

00792 {
00793   int result;
00794 
00795   if (is_multicast)
00796     {
00797       TAO_AV_UDP_MCast_Flow_Handler *handler;
00798       ACE_NEW_RETURN (handler,
00799                       TAO_AV_UDP_MCast_Flow_Handler,
00800                       -1);
00801 
00802       flow_handler = handler;
00803 
00804       result = handler->get_mcast_socket ()->subscribe (*inet_addr);
00805       if (result < 0)
00806         ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_UDP_MCast_connector::open failed\n"),-1);
00807 
00808       // Now disable Multicast loopback.
00809       // @@Should we make this a policy?
00810 #if defined (ACE_HAS_IP_MULTICAST)
00811       if (handler->get_mcast_socket ()->set_option (IP_MULTICAST_LOOP,
00812                                                     0) < 0)
00813         if (TAO_debug_level > 0)
00814           ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_MCast_Acceptor::multicast loop disable failed\n"));
00815       // @@ This should also be policies.
00816 #endif /*ACE_HAS_IP_MULTICAST*/
00817 
00818       int bufsize = 80 * 1024;
00819       if (handler->get_mcast_socket ()->ACE_SOCK::set_option (SOL_SOCKET,
00820                                                               SO_RCVBUF,
00821                                                               (char *)&bufsize,
00822                                                               sizeof(bufsize)) < 0)
00823         {
00824           bufsize = 32 * 1024;
00825           if (handler->get_mcast_socket ()->ACE_SOCK::set_option (SOL_SOCKET,
00826                                                                   SO_RCVBUF,
00827                                                                   (char *)&bufsize,
00828                                                                   sizeof(bufsize)) < 0)
00829             perror("SO_RCVBUF");
00830         }
00831       ACE_NEW_RETURN (local_addr,
00832                       ACE_INET_Addr ("0"),
00833                       -1);
00834 
00835       if (ct == ACCEPTOR)
00836         {
00837           result = handler->get_mcast_socket ()->get_local_addr (*local_addr);
00838           if (result < 0)
00839             ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Dgram_Connector::open: get_local_addr failed\n"),result);
00840 
00841           local_addr->set (local_addr->get_port_number (),
00842                            local_addr->get_host_name ());
00843           handler->set_peer_addr (local_addr);
00844         }
00845     }
00846   else
00847     {
00848       if (local_addr == 0)
00849         ACE_NEW_RETURN (local_addr,
00850                         ACE_INET_Addr ("0"),
00851                         -1);
00852 
00853       TAO_AV_UDP_Flow_Handler *handler;
00854       ACE_NEW_RETURN (handler,
00855                       TAO_AV_UDP_Flow_Handler,
00856                       -1);
00857 
00858       flow_handler = handler;
00859 
00860       if (ct == ACCEPTOR)
00861         result = handler->open (*inet_addr);
00862       else
00863         result = handler->open (*local_addr);
00864       if (result < 0)
00865         ACE_ERROR_RETURN ((LM_ERROR,"handler::open failed\n"),-1);
00866 
00867       // set the socket buffer sizes to 64k.
00868       int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ;
00869       int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ;
00870 
00871       if (handler->get_socket ()->set_option (SOL_SOCKET,
00872                                               SO_SNDBUF,
00873                                               (void *) &sndbufsize,
00874                                               sizeof (sndbufsize)) == -1
00875           && errno != ENOTSUP)
00876         return 0;
00877       else if (handler->get_socket ()->set_option (SOL_SOCKET,
00878                                                    SO_RCVBUF,
00879                                                    (void *) &rcvbufsize,
00880                                                    sizeof (rcvbufsize)) == -1
00881                && errno != ENOTSUP)
00882         return 0;
00883 
00884       if (ct == CONNECTOR)
00885         handler->set_remote_address  (inet_addr);
00886 
00887       result = handler->get_socket ()->get_local_addr (*local_addr);
00888 
00889       local_addr->set (local_addr->get_port_number (),
00890                        local_addr->get_host_name ());
00891 
00892       char buf [BUFSIZ];
00893       local_addr->addr_to_string (buf, BUFSIZ);
00894 
00895       if (result < 0)
00896         ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Dgram_Connector::open: get_local_addr failed\n"),result);
00897     }
00898 
00899   return 1;
00900 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:48:10 2006 for TAO_AV by doxygen 1.3.6