/// <summary> /// Connect to TN3270 server using the connection details specified. /// </summary> /// <remarks> /// You should set the Audit property to an instance of an object that implements /// the IAudit interface if you want to see any debugging information from this function /// call. /// </remarks> /// <param name="host">Host name or IP address. Mandatory</param> /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param> /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param> public void Connect(string host, int port, string lu) { if (this.currentConnection != null) { this.currentConnection.Disconnect(); this.currentConnection.CursorLocationChanged -= currentConnection_CursorLocationChanged; } try { semaphore.Reset(); this.currentConnection = null; this.currentConnection = new TN3270API(); this.currentConnection.Debug = debug; this.currentConnection.RunScriptRequested += new RunScriptDelegate(currentConnection_RunScriptEvent); this.currentConnection.CursorLocationChanged += currentConnection_CursorLocationChanged; this.currentConnection.Disconnected += apiOnDisconnectDelegate; this.apiOnDisconnectDelegate = new OnDisconnectDelegate(currentConnection_OnDisconnect); // // Debug out our current state // if (sout != null) { sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version + " (c) 2004-2017 Mike Warriner and many others"); #if false sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved"); sout.WriteLine(""); sout.WriteLine("This is free software; you can redistribute it and/or modify it"); sout.WriteLine("under the terms of the GNU Lesser General Public License as"); sout.WriteLine("published by the Free Software Foundation; either version 2.1 of"); sout.WriteLine("the License, or (at your option) any later version."); sout.WriteLine(""); sout.WriteLine("This software is distributed in the hope that it will be useful,"); sout.WriteLine("but WITHOUT ANY WARRANTY; without even the implied warranty of"); sout.WriteLine("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU"); sout.WriteLine("Lesser General Public License for more details."); sout.WriteLine(""); sout.WriteLine("You should have received a copy of the GNU Lesser General Public"); sout.WriteLine("License along with this software; if not, write to the Free"); sout.WriteLine("Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA"); sout.WriteLine("02110-1301 USA, or see the FSF site: http://www.fsf.org."); sout.WriteLine(""); #endif if (firstTime) { firstTime = false; } if (Debug) { Config.Dump(sout); sout.WriteLine("Connect to host \"" + host + "\""); sout.WriteLine(" port \"" + port + "\""); sout.WriteLine(" LU \"" + lu + "\""); sout.WriteLine(" Local IP \"" + _localIP + "\""); } } else { } currentConnection.UseSSL = this.mUseSSL; /// Modified CFCJR Feb/29/2008 to support local IP endpoint if (!string.IsNullOrEmpty(_localIP)) { currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration); } else { currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration); } currentConnection.WaitForConnect(-1); DisposeOfCurrentScreenXML(); currentScreenXML = null; // Force refresh // GetScreenAsXML(); } catch (Exception) { currentConnection = null; throw; } // These don't close the connection try { this.mScreenName = "Start"; Refresh(true, 10000); if (sout != null && Debug == true) { sout.WriteLine("Debug::Connected"); } //mScreenProcessor.Update_Screen(currentScreenXML, true); } catch (Exception) { throw; } return; }
/// <summary> /// Connect to TN3270 server using the connection details specified. /// </summary> /// <remarks> /// You should set the Audit property to an instance of an object that implements /// the IAudit interface if you want to see any debugging information from this function /// call. /// </remarks> /// <param name="host">Host name or IP address. Mandatory</param> /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param> /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param> public void Connect(string host, int port, string lu) { if (currentConnection != null) { currentConnection.Disconnect(); } // // try { mre.Reset(); currentConnection = null; currentConnection = new TN3270API(); currentConnection.Debug = mDebug; currentConnection.RunScriptEvent += new RunScriptDelegate(currentConnection_RunScriptEvent); apiOnDisconnectDelegate = new OnDisconnectDelegate(currentConnection_OnDisconnect); currentConnection.OnDisconnect += apiOnDisconnectDelegate; // // Debug out our current state // if (sout != null) { sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version); sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved"); sout.WriteLine(""); // if (mFirstTime) { mFirstTime = false; } if (Debug) { Config.Dump(sout); sout.WriteLine("Connect to host \"" + host + "\""); sout.WriteLine(" port \"" + port + "\""); sout.WriteLine(" LU \"" + lu + "\""); sout.WriteLine(" Local IP \"" + _localIP + "\""); } } else { } // currentConnection.UseSSL = this.mUseSSL; // /// Modified CFCJR Feb/29/2008 to support local IP endpoint if (!string.IsNullOrEmpty(_localIP)) { currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration); } else { currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration); } // // // currentConnection.WaitForConnect(-1); DisposeOfCurrentScreenXML(); _currentScreenXML = null; // force refresh // GetScreenAsXML(); } catch (Exception) { currentConnection = null; throw; } // these don't close the connection try { this.mScreenName = "Start"; Refresh(true, 40000); if (sout != null && Debug == true) { sout.WriteLine("Debug::Connected"); } //mScreenProcessor.Update_Screen(currentScreenXML, true); } catch (Exception) { throw; } return; }