Inheritance: TransportBase
Example #1
0
        private void Connect(Network network, string address, IPAddress ip, int port)
        {
            try {
                if (!base.Dialog.Visible)
                    return;

                if (ip == null) {
                    Gui.ShowErrorDialog("Unable to resolve hostname.", Dialog);
                    return;
                }

                ITransport transport = new TcpTransport(ip, port, ConnectionType.NodeConnection);
                network.ConnectTo(transport);

                if (Gui.Settings.RecentConnections.IndexOf(address) != -1)
                    Gui.Settings.RecentConnections.Remove(address);

                Gui.Settings.RecentConnections.Insert(0, address);
                Gui.Settings.SaveSettings();

                Dialog.Respond((int)ResponseType.Ok);
            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog(ex.Message, base.Dialog);
            }
        }
Example #2
0
 private void Listen()
 {
     try {
         while (true) {
             Socket socket = listener.AcceptSocket();
             try {
                 ITransport transport = new TcpTransport(socket);
                 LoggingService.LogInfo("New incoming transport: {0}.", transport.ToString());
                 Core.TransportManager.Add(transport);
                 // TransportManager will take care of this
                 // connection now
             } catch (Exception ex) {
                 LoggingService.LogError(ex.ToString());
             }
         }
     } catch (ThreadAbortException) {
         // Someone called StopListening(), that's OK...
     }  catch (Exception ex) {
         LoggingService.LogError("Error in TcpListener.Listen()", ex);
     }
 }