Ejemplo n.º 1
0
        /// <summary>
        ///     Sets up the listen connection to accept incoming connections from peers.
        /// </summary>
        /// <returns>Returns true if successful, else false.</returns>
        private async Task<bool> SetupListenConnection()
        {
            bool result = false;

            if (m_listenConnection == null)
            {
                Logger.Info("Attempting to listen on {0}:{1} ...", LoggerVerboseLevel.High, LISTEN_HOST, LISTEN_PORT);

                m_listenConnection = new Connection();
                result = await m_listenConnection.ListenAsync(LISTEN_PORT, LISTEN_HOST);
            }
            else
            {
                Logger.Error("Lost listening connection, attempting to setup connection again ...", LoggerVerboseLevel.Normal);
                result = await m_listenConnection.RelistenAsync();
            }

            if (result == false)
            {
                Logger.Error("Failed to listen on {0}:{1}", LoggerVerboseLevel.Normal, LISTEN_HOST, LISTEN_PORT);
            }
            else
            {
                Logger.Info("Successfully began listening.", LoggerVerboseLevel.High);
            }

            return result;
        }