TN3270Server?

Topics: Developer Forum, Project Management Forum, User Forum
Mar 12, 2013 at 1:21 PM
Anyone had any luck getting the TN3270 server working? I'm trying to stand up a simple server, but the screens I send are garbage on the client end. Wondering if anyone has a working demo?
Mar 12, 2013 at 1:29 PM

I have been using this code at my office for years now. I wrapped the base class with one specific to my company’s needs and it has been the only way we do screen-scraping for quite some time now.

To follow along in real time, I use Tail for Windows to watch the output of the mainframe screens and see exactly what is going on.

Have you had no success at all? What do you mean by “the screens I send are garbage on the client end”?


_____________________________________________________ This message contains information which is privileged and confidential and is solely for the use of the intended recipient. If you are not the intended recipient, be aware that any review, disclosure, copying, distribution, or use of the contents of this message is strictly prohibited. If you have received this in error, please destroy it immediately and notify us at PrivacyAct@torchmarkcorp.com. ­­
Mar 12, 2013 at 1:39 PM
Thanks for the reply.. I've implemented my server like so, and I think I'm just trying to send three ascii 0's to the client. The client connects, but what I'm receiving on my terminal screen is the "Â" character...

public class MyTerminalServer : TN3270ServerEmulationBase
 {
     public override TN3270ServerEmulationBase CreateInstance(Socket sock)
     {
         var server = new MyTerminalServer();
         server.Init(sock);
         return server;
     }


     public override void Run()
     {

        this.Send(new TNServerScreen(0,0) {fFormatted = false, inExtendedMode = false, mScreenBytes = new byte[]{48,48,48} });
         //this.Send("48");
         this.Wait();
     }
 }
Mar 12, 2013 at 1:55 PM
Edited Mar 12, 2013 at 2:06 PM
I built this code into a library, then wrapped it with one specific for my uses. Below is my virtual Connect method that I use, for instance…
public virtual bool Connect(string user, string password, string lu)
        {
            LogMethod("Connect()");
            
            string regionMenuChoice = "";
            if (emulator != null)
                emulator.Close();
            emulator = new TNEmulator();
            emulator.Config.FastScreenMode = false;
            emulator.Config.DefaultTimeout = 3000;
            emulator.Config.TermType = "IBM-3279-4-E";
            emulator.Config.HostPort = 23;
            emulator.Config.HostName = "myserver.mydomain.com"
            emulator.Audit = auditLog;
            emulator.Config.ThrowExceptionOnLockedScreen = true;
            emulator.Debug = true;
            if(_traceSettings.Count > 0)
            {
                emulator.Config.TraceAnsi = _traceSettings["Ansi"];
                emulator.Config.TraceDS = _traceSettings["DS"];
                emulator.Config.TraceDSN = _traceSettings["DSN"];
                emulator.Config.TraceEvent = _traceSettings["Event"];
                emulator.Config.TraceNetworkData = _traceSettings["NetworkData"];
            }
            
            bool retVal = false;
            
            regionMenuChoice = SetRegionChoice(lu);
            //LU must be empty to work with MENU system
            emulator.Config.HostLU = "";
            emulator.Connect();
            if (IsConnected())
            {
                if (this.WaitForText(1, 0, "MYSCREENHEADER", 3000))
                {
                    if (!this.SendText(regionMenuChoice))
                    {
                        Disconnect();
                        return false;
                    }
                    if (!this.SendKey(true, "ENTER"))
                    {
                        Disconnect();
                        return false;
                    }
                    if (this.WaitForText(1, 0, "Signon to CICS on the MAINFRAME", 3000))
                    {
                        string tempHolder = ""; 
                        Log("Found Login screen, sending login info");
                        if (!this.SendText(user))
                        {
                            Disconnect();
                            return false;
                        }
                        if (!this.SendKey(true, "TAB"))
                        {
                            Disconnect();
                            return false;
                        }
                        if (!this.SendText(password))
                        {
                            Disconnect();
                            return false;
                        }
                        if (!this.SendKey(true, "ENTER"))
                        {
                            Disconnect();
                            return false;
                        }
                         if (this.WaitForText(1, 0, "TSS", 1000))
                        {
                            tempHolder = this.GetRow(0).Trim();
                            Log("Something wrong with login: " + tempHolder);
                            if (tempHolder.Contains("TSS7101E Password is Incorrect") ||
                                tempHolder.Contains("TSS7141E Use of Accessor ID Suspended") ||
                                tempHolder.Contains("TSS7160E") ||
                                tempHolder.Contains("TSS7172E Your Accessor ID is Already in Use On Terminal") ||
                                tempHolder.Contains("TSS7110E Password Has Expired"))
                            {
                                Logoff();
                                throw new Exception(tempHolder);
                            }
                        }
                        if (this.WaitForText(1, 13, "SGN", 1000))
                        {
                            tempHolder = this.GetRow(13).Trim();
                            if (
                                tempHolder.Contains(
                                    "SGN003A  New Password REQUIRED.  Enter your password and a new password.") ||
                                tempHolder.Contains("SGN005A  Invalid Userid and/or Password.  Please reenter both.") ||
                                tempHolder.Contains("SGN010A  Contact HELP DESK, Access to terminal/facility denied.") ||
                                tempHolder.Contains("SGN011A  Userid is ALREADY in use, at another terminal."))
                            {
                                Logoff();
                                throw new Exception(tempHolder);
                            }
                        }
                        retVal = this.WaitForText(21, 0, "is complete.", 3000);
                    }
                    else
                        Disconnect();
                }
                else Disconnect();
            }
            return retVal;
        }
Mar 12, 2013 at 2:27 PM
Thanks,

I'm trying to use the server piece to emulate the host. Have you gotten that to work?
Mar 12, 2013 at 2:31 PM
Actually no, my applications are all client apps that each call the mainframe directly.

On Mar 12, 2013, at 9:27 AM, "btompkins" <notifications@codeplex.com> wrote:

From: btompkins

Thanks,

I'm trying to use the server piece to emulate the host. Have you gotten that to work?

_____________________________________________________ This message contains information which is privileged and confidential and is solely for the use of the intended recipient. If you are not the intended recipient, be aware that any review, disclosure, copying, distribution, or use of the contents of this message is strictly prohibited. If you have received this in error, please destroy it immediately and notify us at PrivacyAct@torchmarkcorp.com. ­­ --Apple-Mail-3206D950-9B1C-4941-83B9-BE359163B9E8--
Dec 12, 2016 at 9:49 PM
@btompkins - any lucky getting the server working and creating an app? I'd like to do the same and I'm not sure where to start.
Dec 14, 2016 at 8:31 AM
Hi btompkins, I managed to get this to work, I can send my code if it helps (a variation on yours). It doesn't do much other than return a new date time on every key press :-) but shows it working.
Mar 28 at 2:06 PM
can you create a branch and check it in?