コード例 #1
0
        public void Start()
        {
            IPAddress     address = _endpoint.EndPointIPAddress;
            AddressFamily family  = address.AddressFamily;

            // Multicast socket - used for receiving multicast GENA event messages
            Socket socket = new Socket(family, SocketType.Dgram, ProtocolType.Udp);

            _endpoint.GENA_UDP_MulticastReceiveSocket = socket;
            try
            {
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                NetworkHelper.BindAndConfigureGENAMulticastSocket(socket, address);
                StartReceive(new UDPAsyncReceiveState <EndpointConfiguration>(_endpoint, UPnPConsts.UDP_GENA_RECEIVE_BUFFER_SIZE, socket));
            }
            catch (Exception e) // SocketException, SecurityException
            {
                UPnPConfiguration.LOGGER.Info("GENAClientController: Unable to bind to multicast address(es) for endpoint '{0}'", e,
                                              NetworkHelper.IPAddrToString(address));
            }
        }