Exemple #1
0
        /// <summary>
        ///     Connects a Telnet object to the host using the parameters provided
        /// </summary>
        /// <param name="audit">IAudit interface to post debug/tracing to</param>
        /// <param name="host">host ip/name</param>
        /// <param name="port">port to use</param>
        /// <param name="lu">lu to use or empty string for host negotiated</param>
        /// <param name="config">configuration parameters</param>
        /// <returns></returns>
        public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config)
        {
            if (tn != null)
            {
                tn.CursorLocationChanged -= tn_CursorLocationChanged;
            }

            tn = new Telnet(this, audit, config);

            tn.Trace.optionTraceAnsi        = debug;
            tn.Trace.optionTraceDS          = debug;
            tn.Trace.optionTraceDSN         = debug;
            tn.Trace.optionTraceEvent       = debug;
            tn.Trace.optionTraceNetworkData = debug;

            tn.telnetDataEventOccurred += tn_DataEventReceived;
            tn.CursorLocationChanged   += tn_CursorLocationChanged;

            if (lu == null || lu.Length == 0)
            {
                tn.Lus = null;
            }
            else
            {
                tn.Lus = new List <string>();
                tn.Lus.Add(lu);
            }

            if (!string.IsNullOrEmpty(sourceIP))
            {
                tn.Connect(this, host, port, sourceIP);
            }
            else
            {
                tn.Connect(this, host, port);
            }

            if (!tn.WaitForConnect())
            {
                tn.Disconnect();
                var text = tn.DisconnectReason;
                tn = null;
                throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null);
            }
            tn.Trace.WriteLine("--connected");

            return(true);
        }
Exemple #2
0
        public void Connect(string address, int port)
        {
            Disconnect();

            ChiConsole.WriteLine("Connecting to {0}:{1}", address, port);
            m_telnet.Connect(address, port);
        }
Exemple #3
0
        public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config)
        {
            tn        = new Telnet(this, audit, config);
            tn.UseSSL = mUseSSL;
            tn.trace.optionTraceAnsi        = mDebug;
            tn.trace.optionTraceDS          = mDebug;
            tn.trace.optionTraceDSN         = mDebug;
            tn.trace.optionTraceEvent       = mDebug;
            tn.trace.optionTraceNetworkData = mDebug;
            tn.telnetDataEvent += new TelnetDataDelegate(tn_telnetDataEvent);
            if (lu == null || lu.Length == 0)
            {
                tn.lus = null;
            }
            else
            {
                tn.lus = new System.Collections.ArrayList();
                tn.lus.Add(lu);
            }

            tn.Connect(this, host, port);
            if (!tn.WaitForConnect())
            {
                tn.Disconnect();
                string text = tn.DisconnectReason;
                tn = null;
                throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null);
                //return false;
            }
            tn.trace.WriteLine("--connected");
            return(true);
        }
Exemple #4
0
        public void Connect(string address, int port)
        {
            if (m_telnet.IsConnected)
            {
                m_telnet.Disconnect();
            }

            m_telnet.Connect(address, port);
        }
Exemple #5
0
        public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config)
        {
            tn        = new Telnet(this, audit, config);
            tn.UseSSL = mUseSSL;
            tn.trace.optionTraceAnsi        = mDebug;
            tn.trace.optionTraceDS          = mDebug;
            tn.trace.optionTraceDSN         = mDebug;
            tn.trace.optionTraceEvent       = mDebug;
            tn.trace.optionTraceNetworkData = mDebug;

            tnDataDelegate      = new TelnetDataDelegate(tn_telnetDataEvent); // CFC,Jr 8/2/2008
            tn.telnetDataEvent += tnDataDelegate;

            if (lu == null || lu.Length == 0)
            {
                tn.lus = null;
            }
            else
            {
                tn.lus = new System.Collections.ArrayList();
                tn.lus.Add(lu);
            }

            // Modified CFCJR Feb/29/2008 to allow for local IP endpoint
            if (!string.IsNullOrEmpty(_sourceIP))
            {
                tn.Connect(this, host, port, _sourceIP);
            }
            else
            {
                tn.Connect(this, host, port);
            }

            if (!tn.WaitForConnect())
            {
                tn.Disconnect();
                string text = tn.DisconnectReason;
                tn = null;
                throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null);
                //return false;
            }
            tn.trace.WriteLine("--connected");
            return(true);
        }
Exemple #6
0
    /// <summary>
    /// Connects to the remote server and starts receiving data to write to the display.
    /// </summary>
    public void Connect(object state)
    {
        //Necessary for explicit security
        EventHandler <CommandEventArgs> commandReceivedHandler =
            new EventHandler <CommandEventArgs>(telnet_CommandReceived);

        try
        {
            //Connect to the server
            Telnet.Connect(session);
            Telnet.Socket.ReceiveTimeout = 5000;

            //If Explicit security used, use the CommandReceived event to negotiate
            if (securityType == SecurityType.Explicit)
            {
                Telnet.CommandReceived += commandReceivedHandler;
            }
            //If Implicit security used, authenticate server and specify certificate callback functions
            else if (securityType == SecurityType.Implicit)
            {
                Telnet.AuthenticateAsClient(security);
            }

            //Login and provide transferred data to the interface (Data event)
            if (session.RemoteEndPoint.Port > 0 && credentials.Username.Length > 0 &&
                credentials.Password.Length > 0)
            {
                Data data = Telnet.Login(credentials);
                Telnet.Marshal(data, string.Empty, null);
            }

            //Provide telnet.Stream to interface (UserState event), or start the read loop.
            Telnet.Socket.ReceiveTimeout = 0;
            if (ReceiveLoopRequired)
            {
                ReceiveData();
            }
            else
            {
                Telnet.Marshal("", Telnet.GetStream());
            }
        }
        catch (Exception ex)
        {
            Telnet.Marshal(ex);
        }
        finally
        {
            Telnet.CommandReceived -= commandReceivedHandler;
        }
    }
        /// <summary>
        ///
        /// </summary>
        public TN3270HostParser()
        {
            Open3270.ConnectionConfig config = new ConnectionConfig();
            config.HostName = "DUMMY_PARSER";
            TN3270API api = new TN3270API();

            telnet = new Telnet(api, this, config);
            telnet.Trace.optionTraceAnsi        = true;
            telnet.Trace.optionTraceDS          = true;
            telnet.Trace.optionTraceDSN         = true;
            telnet.Trace.optionTraceEvent       = true;
            telnet.Trace.optionTraceNetworkData = true;
            telnet.telnetDataEventOccurred     += new TelnetDataDelegate(telnet_telnetDataEvent);

            telnet.Connect(null, null, 0);
        }
Exemple #8
0
        private void butConnect_Click(object sender, EventArgs e)
        {
            try
            {
                if (telnet == null)
                {
                    telnet = new Telnet();
                }

                string strIpAddress = txtIPAddress.Text;
                int    intPort      = Convert.ToInt16(txtPort.Text);

                telnet.Connect(strIpAddress, intPort);

                if (telnet.Connected == true)
                {
                    richtxtLogInfo.AppendText("服务器 " + strIpAddress + ":" + intPort + " 连接成功。\r\n");
                    richtxtLogInfo.AppendText(telnet.WaitFor("login:"******"cq");
                    richtxtLogInfo.AppendText(telnet.WaitFor("password:"******"windows001");
                    richtxtLogInfo.AppendText(telnet.WaitFor(">"));
                    telnet.Send("dir");
                    richtxtLogInfo.AppendText(telnet.WaitFor(">"));
                    telnet.Send("cd Favorites");
                    richtxtLogInfo.AppendText(telnet.WaitFor(">"));
                    telnet.Send("dir");
                    richtxtLogInfo.AppendText(telnet.WaitFor(">"));
                }

                telnet.Close();
                telnet = null;
            }
            catch (Exception exc)
            {
                richtxtLogInfo.AppendText(exc.Message);
            }
        }
        public ActionResult Video(string path, string file)
        {
            KillVLCProc();
            RunVLC();
            Guid vodId = Guid.NewGuid();
            using (var telnet = new Telnet()) {
                telnet.Connect("127.0.0.1", 4212);
                telnet.Send("admin"); // password
                telnet.Receive();
                telnet.Send(string.Format("new {0} broadcast enabled", vodId));
                telnet.Receive();
                telnet.Send(string.Format("setup {0} input \"{1}\"", vodId, Path.Combine(path, file)));
                telnet.Receive();
                //telnet.Send(string.Format("setup {0} mux mov", vodId)); // mp4 mp2t mp2p ts ps mp2v mp4v avi asf
                telnet.Send("setup {0} output #transcode{$t}:gather:rtp{mp4a-latm,sdp=rtsp://0.0.0.0/{0}.sdp}"
                                .Replace("{0}", vodId.ToString())
                                .Replace("$t", TranscoderSettings));
                telnet.Receive();
                telnet.Send(string.Format("control {0} play", vodId));
                telnet.Receive();
            }

            return Redirect(string.Format("rtsp://{0}/{1}.sdp", Request.Url.Host, vodId));
        }
Exemple #10
0
 /// <summary>
 /// 连接OLT设备
 /// </summary>
 /// <param name="IpAddress"></param>
 /// <param name="Port"></param>
 /// <returns></returns>
 public string Connect(string IpAddress, int Port)
 {
     telnet.Connect(IpAddress, Port);
     //telnet.WaitFor(
     return("");
 }