Gilly400
23625 pts. | Aug 26 2008 8:47AM GMT
Hi,
If you’re IPL’ing the AS400, then it’s not the AS400 that’s keeping the connection open. If you IPL, then everthing is shutdown and restarted, including all communications. When the AS400 is restarted, then maybe it creates a new connection, but the old connection should be gone, unless the machine at the other end re-opens it. I suggest you check whatever is on the other end of your connection.
Regards,
Martin Gilbert.
LHrabar
95 pts. | Aug 26 2008 7:04PM GMT
The device os a small TCP/IP-> Com port converter box which listens for a connection. The iSeries connects to this converter using TCP/IP. If we end the program that connects, or the subsystem that it runs in, and then restart the process the iSeries does not drop the connection. It will if we let it time out, but most of the time the stop/start happens within a few seconds. I would like to add an ENDTCPCNN command to make sure that the connection is closed, but the command requires the local port number. The connection is setup to connect to port yyyy on the converter. The iSeries will use any available port. I am looking for a way to get the local port number in a program. I know I can use netstat/wrktcpsts to find the port, but I am trying to automate the process so the operators do not have to find the local port number and manually enter the endtcpcnn command.
Mcl
2500 pts. | Aug 26 2008 8:46PM GMT
Unfortunately, the ENDTCPCNN command exists so that you can limit authority to ending connections through NETSTAT.
The connections should time out and drop, but other than that I think you can only end the connection using NETSTAT. Take option #3, scroll down through the list and end with option #4.
Regards
Mike
LHrabar
95 pts. | Aug 28 2008 2:31PM GMT
Thanks for all the answers. What I am looking to do is to not have the operators, or anyone, have to lookup the port number and end the connection (using ENDTCPCNN ro NETSTAT/Opt#3/Opt#4). I would like to have a program retrieve the local port number and end the connection. No manual intervention needed.
Bvining
4785 pts. | Aug 29 2008 4:22PM GMT
You have a few options here.
If you have the source for the application program you could:
1. Use the bind() API (long name of Set Local Address for Socket) to turn off the port selection by the system. Just use a fixed port number and that’s what you’ll cancel on.
2. After you have established the connection use the getsockname() API (long name of Get Local Address of Socket). Given the socket desriptor the API will return to you the local address. This local address includes the port number. You could write the port number to a *DTAARA and use this stored value later, if needed, to end the connection. Using this approach I would lean towards clearing the value upon a successful close of the connection.
If you don’t have the source for the application program then you can get at the data that NetStat drives off of with the QtocLstNetCnn API (long name of List Network Connections). This API also returns port information.
I hope this helps,
Bruce Vining
<a href="http://www.brucevining.com/" title="http://www.brucevining.com/" target="_blank">http://www.brucevining.com/</a>
LHrabar
95 pts. | Sep 2 2008 2:42PM GMT
Thanks bvining,
After adding the bind call to my program, I was able to control the local port number. Adding the ENDTCPCNN command was just as easy. I have tested the ENDSBS/STRSBS a few times, and it works great.
Thanks to all who responded,
Len






