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>
Public Types | |
enum | ConnectionType { CONNECTOR, ACCEPTOR } |
Indicates whether this setup is for a Connector or an Acceptor. More... | |
Static Public Member Functions | |
static int | setup (TAO_AV_Flow_Handler *&flow_handler, ACE_INET_Addr *inet_addr, ACE_INET_Addr *&local_addr, int is_multicast, ConnectionType ct) |
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.
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 796 of file UDP.cpp.
{ int result; if (is_multicast) { TAO_AV_UDP_MCast_Flow_Handler *handler; ACE_NEW_RETURN (handler, TAO_AV_UDP_MCast_Flow_Handler, -1); flow_handler = handler; result = handler->get_mcast_socket ()->join (*inet_addr); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_UDP_MCast_connector::open failed\n"),-1); // Now disable Multicast loopback. // @@Should we make this a policy? #if defined (ACE_HAS_IP_MULTICAST) if (handler->get_mcast_socket ()->set_option (IP_MULTICAST_LOOP, 0) < 0) if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_MCast_Acceptor::multicast loop disable failed\n")); // @@ This should also be policies. #endif /*ACE_HAS_IP_MULTICAST*/ int bufsize = 80 * 1024; if (handler->get_mcast_socket ()->ACE_SOCK::set_option (SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize)) < 0) { bufsize = 32 * 1024; if (handler->get_mcast_socket ()->ACE_SOCK::set_option (SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize)) < 0) ACE_OS::perror("SO_RCVBUF"); } ACE_NEW_RETURN (local_addr, ACE_INET_Addr ("0"), -1); if (ct == ACCEPTOR) { result = handler->get_mcast_socket ()->get_local_addr (*local_addr); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Dgram_Connector::open: get_local_addr failed\n"),result); local_addr->set (local_addr->get_port_number (), local_addr->get_host_name ()); handler->set_peer_addr (local_addr); } } else { if (local_addr == 0) ACE_NEW_RETURN (local_addr, ACE_INET_Addr ("0"), -1); TAO_AV_UDP_Flow_Handler *handler; ACE_NEW_RETURN (handler, TAO_AV_UDP_Flow_Handler, -1); flow_handler = handler; if (ct == ACCEPTOR) result = handler->open (*inet_addr); else result = handler->open (*local_addr); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"handler::open failed\n"),-1); // set the socket buffer sizes to 64k. int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; if (handler->get_socket ()->set_option (SOL_SOCKET, SO_SNDBUF, (void *) &sndbufsize, sizeof (sndbufsize)) == -1 && errno != ENOTSUP) return 0; else if (handler->get_socket ()->set_option (SOL_SOCKET, SO_RCVBUF, (void *) &rcvbufsize, sizeof (rcvbufsize)) == -1 && errno != ENOTSUP) return 0; if (ct == CONNECTOR) handler->set_remote_address (inet_addr); result = handler->get_socket ()->get_local_addr (*local_addr); local_addr->set (local_addr->get_port_number (), local_addr->get_host_name ()); ACE_TCHAR buf [BUFSIZ]; local_addr->addr_to_string (buf, BUFSIZ); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Dgram_Connector::open: get_local_addr failed\n"),result); } return 1; }