Esempio n. 1
0
        public bool StartConnection(NetConnectionSettings WithConfig)
        {
            //jeśli jesteśmy już połączeni, nie łączymy się jeszcze raz
            if (ConnectionOpened)
            {
                throw new Exception("already_connected");
            }

            try
            {
                NetSocket = new TcpClient(WithConfig.Hostname, WithConfig.Port);
                if (WithConfig.UseSsl)
                {
                    SslStream Ssl = new SslStream(NetSocket.GetStream());
                    Ssl.AuthenticateAsClient(WithConfig.Hostname);
                    NetStream = Ssl;
                }
                else
                {
                    NetStream = NetStream = NetSocket.GetStream();
                }
            }
            catch (Exception e)
            {
                throw new Exception("connection_init_error: " + e.ToString());
            }

            return(true);
        }
 public void CloneFrom(NetConnectionSettings In)
 {
     Hostname     = In.Hostname;
     Port         = In.Port;
     UserLogin    = In.UserLogin;
     UserPassword = In.UserPassword;
     UseSsl       = In.UseSsl;
     CloneChildData(In);
 }
 public abstract void CloneChildData(NetConnectionSettings InSettings);
 public override void CloneChildData(NetConnectionSettings InSettings)
 {
     UnixListing = ((FtpConnectionSettings)InSettings).UnixListing;
 }