Beispiel #1
0
        private void StartNewUDPConnectedChannel(Uri connection)
        {
            ConnectionInfo info = new ConnectionInfo();
            info.Addr = connection.DnsSafeHost;
            info.Port = connection.Port;

            UDPMessageChannel channel = new UDPMessageChannel(null, info);
            AddChannel(channel);
            if (log.IsDebugEnabled)
                log.Debug("Created UDP Channel running in port " + channel.udpSocket.LocalEndPoint +
                          " remote addrs: " + channel.udpSocket.RemoteEndPoint);
        }
Beispiel #2
0
        /// <summary>
        /// Create a new UDP Channel using the connection info supplied by parameter.
        /// Start a new thread to process new connections
        /// </summary>
        /// <param name="info">information for the connection, including address and port</param>
        /// <returns> the created channel </returns>
        public UDPMessageChannel StartNewUDPLocalChannel(ConnectionInfo info)
        {
            UDPMessageChannel channel = null;
            lock (this)
            {
                try
                {
                    channel = new UDPMessageChannel(info, null);
                    if (channel == null)
                    {
                        return null;
                    }

                    AddChannel(channel);
                    if (log.IsDebugEnabled)
                        log.Debug("Created UDP Channel running in port " + channel.udpSocket.LocalEndPoint);
                }
                catch (SocketException e)
                {
                    if (log.IsWarnEnabled)
                        log.Warn("Can't open socket running in port :" + e.Message);
                    //maybe it is in use. Just Return.
                    return null;
                }
                catch (Exception e)
                {
                    throw e;
                }
                return channel;
            }
        }