Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Determining IP Address

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Determining IP Address

    We have remote AS/400s connecting to a host AS/400 with dial up connections through an ISP. The ISP randomly assigns IP addresses to the remotes. Is there any way to programaticly retrieve the ISP assigned IP address for the remotes from either the remotes or the host? Thanks, Larry

  • #2
    Determining IP Address

    Hi Larry, Certainly in java, and I'm sure in other forms of socket programming, one can get the INetAddress of both local/remote ( or client/server ) participants. Assuming that your host ( or at least one of the 400s ) has a permanent address: There could be a server socket program on your host/main 400. Then, you could have some sort of script ( I'm including CL here ) so that the remote runs a client socket connect immediately after connecting with the ISP. Once the sockets have talked, the address info can be put where ever it is useful to you. This is off the top of my head, but should provide what you are after. If none of the 400s have a permanent adress, it's difficult to see how to automate that without specific help from your ISP. Best, Joe Sam Joe Sam Shirah Autumn Software Consulting/Development/Outsourcing Please Note New Email: jshirah@attglobal.net Visit our User Group at: http://www.jax400.com

    Comment


    • #3
      Determining IP Address

      Hi Joe Sam, The host has a fixed IP address. I'm using RPG ILE calling APIs for the sockets programs. Is there an API that will return the IP address of the client? I've tried calling 'GetHostId()' on the clients, but it returns 0. Regards, Larry

      Comment


      • #4
        Determining IP Address

        Larry, I canobolized the following code from IBM's CODE/400 web site. It returns the IP of the client.
         PGM (&SERVER &PORT &PARMS) DCL VAR(&SERVER) TYPE(*CHAR) LEN(8) DCL VAR(&PORT) TYPE(*CHAR) LEN(5) DCL VAR(&PARMS) TYPE(*CHAR) LEN(32) DCL VAR(&BIN4) TYPE(*CHAR) LEN(4) DCL VAR(&RCV) TYPE(*CHAR) LEN(893) DCL VAR(&RCVLEN) TYPE(*CHAR) LEN(4) DCL VAR(&RCVLEND) TYPE(*DEC) LEN(9) DCL VAR(&ERR) TYPE(*CHAR) LEN(100) DCL VAR(&DEC8) TYPE(*DEC) LEN(8 0) DCL VAR(&FRMCFG) TYPE(*CHAR) LEN(8) VALUE('CFGD0200') DCL VAR(&DEVD) TYPE(*CHAR) LEN(10) DCL VAR(&FRMDEV) TYPE(*CHAR) LEN(8) VALUE('DEVD0600') DCL VAR(&IP) TYPE(*CHAR) LEN(15) DCL VAR(&PASTHR) TYPE(*CHAR) LEN(1) CHGVAR VAR(&RCVLEND) VALUE(893) CHGVAR VAR(%BIN(&RCVLEN)) VALUE(&RCVLEND) RTVJOBA JOB(&DEVD) CHGVAR VAR(%BINARY(&BIN4)) VALUE(&DEC8) CALL PGM(QDCRDEVD) PARM(&RCV &RCVLEN &FRMDEV + &DEVD &ERR) CHGVAR VAR(&PASTHR) VALUE(%SST(&RCV 831 1)) CHGVAR VAR(&IP) VALUE(%SST(&RCV 878 15)) STRCODE SERVER(&SERVER) RMTLOCNAME(&IP) + CMNTYPE(*TCPIP) PARMS(&PARMS) PORT(&PORT) ENDPGM: ENDPGM
        David Morris

        Comment


        • #5
          Determining IP Address

          David, Thanks, I'll try to adapt it to what I'm doing. Regards, Larry

          Comment


          • #6
            Determining IP Address

            Hi Larry, I'm not ignoring you, but I ( personally ) would do this in java and want to check up on a few things when I have time for this sort of thing. Because I believe in the right tool for the right job, I've tended to stay away from sockets in RPG. Also, while I've done lots in C, never got to sockets there. If the CL stuff sent in a previous message was not enough, you may want to look over: Who Knew You Could Do That with RPG IV? A Sorcerer's Guide to System Access and More SG24-5402-00 http://www.redbooks.ibm.com/abstracts/sg245402.html which has some sockets examples, although apparently not of what you want to do. Also: 8.4 accept_and_recv()--Wait for Connection Request and Receive the First Message That Was Sent ¦ Syntax ¦ ¦ #include ¦ #include ¦ ¦ int accept_and_recv(int listen_socket_descriptor, ¦ int *accept_socket_descriptor, ¦ struct sockaddr *remote_address, ¦ size_t *remote_address_length, ¦ struct sockaddr *local_address, ¦ size_t *local_address_length, ¦ void *buffer, ¦ size_t buffer_length ¦ ¦ ¦ Threadsafe: Yes ¦ from System API Reference OS/400 UNIX-Type APIs Version 4 Document Number SC41-5875-03 The above shows remote address, but none of this looks like fun in RPG or C, so much simpler in java. Anyhow, that should hold you until I get back; may be Monday. In the meantime, Good Luck! Best, Joe Sam

            Comment


            • #7
              Determining IP Address

              Hi Larry, Followup as promised: 1) This can be done and will work. 2) I finally got some time and, despite some problems with the IPP servicing the 400, was able to confirm that it is fairly straightforward in java. My test was between NT and a 400, but I see no reason for differences in 400 to 400 communication. For those interested, here's what I did: Slightly modified the KnockKnockClient/Server example from The Java Tutorial ( being lazy, ) and added code for getInetAddress() to get the client address. Created a copy of the client that allowed sending the address as an argument. Sent the server and version 2 of the client to the 400. Started the server on the 400, then ran the client on NT and obtained the client ( NT ) addresss put to the 400 server program. Ended both programs. Started the server on NT and V2 of the client on the 400, passing the address retrieved from the first run. Bang, the programs talked and the server on NT now showed the 400's address. Possibly the most impressive thing about this is that I sent the classes *compiled* on NT as is to the 400 and they ran ( WORA is not quite A or in all cases yet, but this certainly says something to me. ) A couple of other things if you want to continue on the RPG/C path: I took a quick look at the QDCRDEVD program mentioned before and, as one might expect from the name, it gets information from a device ( which appears to generally be a display. ) You may be able to do something with it, but hard to see how to use it in terms of starting it up programmatically, etc. Second, it appears to me that the accept() function also has this information. See the description of sockaddr in int accept(int socket_descriptor, struct sockaddr *address, int *address_length) I don't usually ( and can't, really ) spend this much time on a forum answer, but it was of interest and some fun to do. I wish you well on your own resolution and hope you will report results back here. Best, Joe Sam

              Comment


              • #8
                Determining IP Address

                I guess I don't know enough network 'engineering' to understand the problem. But here's what I do; on the M$ box do C:>ipconfig > I:NTADDRipnbr.txt I: is mapped to QDLS on the 400. On the 400 with a REXX proc, I read the ipnbr.txt file until I find a line that says e.g. I.P.Address.............123.123.123.12 which gives me the IP address.

                Comment


                • #9
                  Determining IP Address

                  Possibly the most impressive thing about this is that I sent the classes *compiled* on NT as is to the 400 and they ran ( WORA is not quite A or in all cases yet, but this certainly says something to me. ) According to the Java specifications, WORA is actually required by the JVM. In fact, I haven't found a situation where Java bytecode compiled on one machine won't run on another, except when the second machine simply doesn't support certain features (like trying to run GUI classes on the AS/400). I haven't compiled a class on the AS/400 in over six months; I do all my development in VAJava and export directly to the IFS that's mapped to a drive via Client Access. The only thing I do on the AS/400 is run CRTJVAPGM once a class or jar file gets stable enough to sit around a while. This is the coolest thing in the world for me. It means I can do all my testing locally on my workstation (I even wrote a little WebSphere emulator) and then just upload to the AS/400, secure in the knowledge that my classes will run on the AS/400 without a hitch, as long as my environment is set up correctly. src="//www.zappie.net/java/_derived/index.htm_cmp_zero110_vbtn_p.gif" width="140" height="60" border="0" alt="Java400.net - Java/400 Freeware" align="middle"> Java400.Net - where the AS/400 speaks Java with an RPG accent Home of PBD2.0, the color=red>FREE Java/400 Client/Server color=blue>Revitalization Toolkit

                  Comment


                  • #10
                    Determining IP Address

                    Hi Bob, The point here was to programmatically connect machines coming in over the internet to a 400 -- without using client access, mapped drives, no other connection at all -- getting the ( probably, since they were coming in over a dialup ISP, ) varying address and being able to start up other connections to the obtained address. I'm sure REXX could do that in some form. I've had several discussions with Mike Cowlishaw at CSS conferences and elsewhere -- they don't come much brighter, he even has submitted a better BigDecimal class for java -- and he probably put in a way. If you'd care to submit a sample, I'm sure Larry would be appreciative. Please keep it platform independent to be on a par with the sockets version ( java or otherwise, ) which should work with almost any other kind of box. Best, Joe Sam

                    Comment


                    • #11
                      Determining IP Address

                      This CL program from Craig Pelkie of Bits & Bytes Programming may help.

                      Comment


                      • #12
                        Determining IP Address

                        >I guess I don't know enough network 'engineering' to understand the problem. But here's what I do; >>on the M$ box do C:>ipconfig > I:NTADDRipnbr.txt I: is mapped to QDLS on the 400. >>On the 400 with a REXX proc, I read the ipnbr.txt file until I find a line that says e.g.
                        >>I.P.Address.............123.123.123.12 which gives me the IP address. An alternate way to get this info to a PC file (if you want to do it this way) is to use the netstat command on your PC and upload it a location on the AS/400 IFS as Bob suggests. To do this, perform netstat with the -n parameter (numerical format for IP addresses) as follows: netstat -n>info.dat This will produce a file that contains information similar to the following: Active Connections Proto Local Address Foreign Address State TCP 10.1.198.1:1657 10.2.55.1:23 ESTABLISHED TCP 10.1.198.1:1907 10.2.55.1:449 ESTABLISHED TCP 10.1.198.1:1681 10.2.78.1:1352 ESTABLISHED Then you parse the address from the local address (after you strip off the port number) to get the address of your PC client. There's also two interesting things that netstat on the PC has in addition to the IPCONFIG command that Bob presented. 1. It shows the IP addresses for both your local machine and the TCP/IP host you're connected to. This way you can match up your clients to the hosts they are connected to. In this example here, I'm connected to an AS/400 (10.2.55.1) as well as to a Notes host (10.2.78.1). It will also show you the IP addresses of any Web servers, FTP hosts, etc. that you're talking to. 2. It shows the port numbers your local client is using as well as the ports on the host machine that it is talking to (the ':' numbers after the address). For example, if you want to monitor all telnet sessions on your AS/400, you'd scan for port 23 in the PC files. In this case, I'd set it to ignore any other ports on 10.2.55.1 that the client is talking to (for this one, port 449 is using an OpsNav connection I have set up). So that's another way you could do it if you're using uploaded TCP/IP info from a PC on your AS/400. Joe Hertvik Editor-AS/400 Network Expert mailto:jhertvik@midrangecomputing.com Looking to hook your AS/400 up to the world? Breaking news, articles, tips, we post it all on the AS/400 Network Expert web site (http://www.midrangecomputing.com/ane). Get in the loop with our **free** weekly email alerts by sending an email to: mailto:jhertvik@midrangecomputing.com?subject=Subs cribe1

                        Comment


                        • #13
                          Determining IP Address

                           Joe Pluta wrote: According to the Java specifications, WORA is actually required by the JVM. In fact, I haven't found a situation where Java bytecode compiled on one machine won't run on another, except when the second machine simply doesn't support certain features (like trying to run GUI classes on the AS/400). 
                          Hey Joe, I'm not disputing this, I'm just asking for clarity. What about Microsoft's version of Java? Does that contain anything that will preclude it from running on, say, a JVM capable Macintosh? I ask because I remember seeing a disclaimer on the product when you first open it in Windows saying something about how the code generated here contains blah blah blah that is exclusive to Microsoft. Just curious...

                          Comment


                          • #14
                            Determining IP Address

                            What about Microsoft's version of Java? There is no such thing anymore. The District Court decision of November 17, 1998, absolutely banned Microsoft from shipping a non-compatible JVM if it wanted to say its products were Java-enabled. Microsoft then had to choose between removing the "Java-enabled" label from its products or shipping a compatible JVM. They chose the latter. Anything shipped since November of 1998 and labeled as a JVM must be 100% compatible with the recognized Java standard. THERE IS ONLY ONE JAVA. If a "JVM" is not compatible with the Sun standard, it is NOT a JVM, and you SHOULD NOT USE IT. DO NOT USE JAVA SOFTWARE THAT IS NOT 100% JAVA COMPATIBLE. If you do so, you seriously risk the success of your project and the ability of your project to take advantage of the incredible leaps in power and productivity of future releases of the JVM. As far as I know, Microsoft no longer produces a non-compatible JVM (nor does anyone else). Instead, the powers that be at Microsoft are pouring all of their development dollars into giving Visual Basic all the features of Java. src="//www.zappie.net/java/_derived/index.htm_cmp_zero110_vbtn_p.gif" width="140" height="60" border="0" alt="Java400.net - Java/400 Freeware" align="middle"> Java400.Net - where the AS/400 speaks Java with an RPG accent Home of PBD2.0, the color=red>FREE Java/400 Client/Server color=blue>Revitalization Toolkit

                            Comment


                            • #15
                              Determining IP Address

                              BTW, how's the Revitalization going?

                              Comment

                              Working...
                              X