[RESOLVED] "Address already in use" exception at connection

Topics: Developer Forum
Feb 10, 2011 at 12:16 PM

Hi folks! 

First, I'd like to thank you for your great work! It's a real pain to find any decent library doing the job, and the mainframe world seams to ended in 2008 (there are barelly any resource updated after this date)....

I'm trying to connect to a local sort-of-proxy which runs on port 23 and route me to the right mainframe, using this code:

 

TNEmulator emulator = new TNEmulator();
emulator.Audit = this;
emulator.Debug = true;
emulator.Config.TermType = "IBM-3278-2-E";
emulator.Config.FastScreenMode = true;
emulator.Connect("127.0.0.1", 23, "MYLUA");

which leads to this exception:

Open3270 emulator version 1.5.0.1(c)

2004-2006 Mike Warriner (mikewarriner@gmail.com).
All rights reserved

Config.FastScreenMode True
Config.IgnoreSequenceCount False
Config.IdentificationEngineOn False
Config.AlwaysSkipToUnprotected True
Config.LockScreenOnWriteToUnprotected False
Config.ThrowExceptionOnLockedScreen True
Config.DefaultTimeout 40000
Config.hostName
Config.hostPort 23
Config.hostLU
Config.termType IBM-3278-2-E
Config.AlwaysRefreshWhenWaiting False
Config.SubmitAllKeyboardCommands False
Config.RefuseTN3270E False
Connect to host "127.0.0.1"
           port "23"
           LU   "MYLU"
     Local IP   ""

ExceptionHostException 'An error occured connecting to the host '127.0.0.1' on port 23' Address already in use.
   à Open3270.TN3270.Telnet.Connect(Object _ParentData, String _address, Int32 _port) dans Telnet.cs:ligne 552
   à Open3270.TN3270.TN3270API.Connect(IAudit audit, String host, Int32 port, String lu, ConnectionConfig config) dans TN3270API.cs:ligne 150
   à Open3270.TNEmulator.Connect(String host, Int32 port, String lu) dans TNEmulator.cs:ligne 656
   à Sample.TheDemo.Run() dans TheDemo.cs:ligne 22
   à Sample.Program.Main(String[] args) dans Program.cs:ligne 13

I can connect to localhost using other standard 3270 emulators, so the problem is not coming from the server. I'm on Vista, and neither running Visual Studio 2008 as an Administrator, neither a reboot does change anything.

I'm behind a firewall, therefore I can't connect to the uconnvm.uconn.edu server for testing (which is accessible from my home computer).

 

Any idea? :)

Feb 10, 2011 at 12:22 PM
The TN3270 is trying to make a connection to your local machine on port 23, yet you are already using port 23 to make that connection. You have a viscious cycle going where your are trying to talk out on port 23 to connect to port 23. Doesn't make sense.


From: ngirardin [email removed]
Sent: Thursday, February 10, 2011 7:16 AM
To: Jason Coffee
Subject: "Address already in use" exception at connection [Open3270:245436]

From: ngirardin

Hi folks!

First, I'd like to thank you for your great work! It's a real pain to find any decent library doing the job, and the mainframe world seams to ended in 2008 (there are barelly any resource updated after this date)....

I'm trying to connect to a local sort-of-proxy which runs on port 23 and route me to the right mainframe, using this code:

TNEmulator emulator = new TNEmulator();
emulator.Audit = this;
emulator.Debug = true;
emulator.Config.TermType = "IBM-3278-2-E";
emulator.Config.FastScreenMode = true;
emulator.Connect("127.0.0.1", 23, "MYLUA");

which leads to this exception:

Open3270 emulator version 1.5.0.1(c)

2004-2006 Mike Warriner (mikewarriner@gmail.com).
All rights reserved

Config.FastScreenMode True
Config.IgnoreSequenceCount False
Config.IdentificationEngineOn False
Config.AlwaysSkipToUnprotected True
Config.LockScreenOnWriteToUnprotected False
Config.ThrowExceptionOnLockedScreen True
Config.DefaultTimeout 40000
Config.hostName
Config.hostPort 23
Config.hostLU
Config.termType IBM-3278-2-E
Config.AlwaysRefreshWhenWaiting False
Config.SubmitAllKeyboardCommands False
Config.RefuseTN3270E False
Connect to host "127.0.0.1"
port "23"
LU "MYLU"
Local IP ""

ExceptionHostException 'An error occured connecting to the host '127.0.0.1' on port 23' Address already in use.
à Open3270.TN3270.Telnet.Connect(Object _ParentData, String _address, Int32 _port) dans Telnet.cs:ligne 552
à Open3270.TN3270.TN3270API.Connect(IAudit audit, String host, Int32 port, String lu, ConnectionConfig config) dans TN3270API.cs:ligne 150
à Open3270.TNEmulator.Connect(String host, Int32 port, String lu) dans TNEmulator.cs:ligne 656
à Sample.TheDemo.Run() dans TheDemo.cs:ligne 22
à Sample.Program.Main(String[] args) dans Program.cs:ligne 13

I can connect to localhost using other standard 3270 emulators, so the problem is not coming from the server. I'm on Vista, and neither running Visual Studio 2008 as an Administrator, neither a reboot does change anything.

I'm behind a firewall, therefore I can't connect to the uconnvm.uconn.edu server for testing (which is accessible from my home computer).

Any idea? :)


_____________________________________________________
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. ­­
Feb 10, 2011 at 2:11 PM

Thank you jcoffee for your quick response!

When spying to the connections with SysInternals TcpView, I saw the proxy relaying my connection to another address, on the 8123 port, so I decided to use these address and port in Open3270 and it worked! :)

After digging into the code I still don't understand why the connection is made to the mainframe with the source port = destination port and why we just don't grab any random free source port.

Is there some reason behind this behavior?

 

Nicolas

Feb 10, 2011 at 2:14 PM
Noramlly, you are connecting to a mainframe's IP address on port 23, not your local machine. You had your code opening 23 on your local machine, not the actual mainframe's IP. Your situation is not most likely not very common.


From: ngirardin [email removed]
Sent: Thursday, February 10, 2011 9:11 AM
To: Jason Coffee
Subject: Re: "Address already in use" exception at connection [Open3270:245436]

From: ngirardin

Thank you jcoffee for your quick response!

When spying to the connections with SysInternals TcpView, I saw the proxy relaying my connection to another address, on the 8123 port, so I decided to use these address and port in Open3270 and it worked! :)

After digging into the code I still don't understand why the connection is made to the mainframe with the source port = destination port and why we just don't grab any random free source port.

Is there some reason behind this behavior?

Nicolas


_____________________________________________________
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. ­­
Feb 10, 2011 at 2:36 PM

You're right, I don't know why do they need to set up a local proxy...

Dec 7, 2011 at 8:25 AM
Edited Dec 7, 2011 at 8:25 AM

Hi Mike Warriner,

 

I am using open 3270 emulator 1.5.0.1. It woks fine on 80x24 screen mode.

 

We need to use it on 80x43. We did the following changes to make it work.

 

protected string HOST_TERMINAL_TYPE = "IBM-3278-2-E";

TO 

 protected string HOST_TERMINAL_TYPE = "IBM-3278-4-E";

 

and 

public int ROWS = 25;

 TO

public int ROWS = 44;

found in TN3270E\X3270\Stuff\Ctlr.cs(217)

 

and then at the end in Render() method we change _cy = 25 to _cy = 44

 

At the end we get connected to mainframe but getting this message "no unprotected field".

 

Can you please help. Is there a work around to use 80x43 screen mode in this emulator?? Thanks

 

Salman