× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Retrieving IP address for sockets
  • From: "Graap, Ken" <keg@xxxxxxxxxxxxxxx>
  • Date: Wed, 28 Oct 1998 15:27:40 -0800

Jeff wrote:

>Is there a programmatic way to determine the IP address of a client in
>order to create a socket to that IP address?

Here is what I use to display the IP address......


/* ************************************************************** */

/* PROGRAM DESCRIPTION :                                          */

/*                                                                */

/* RETRIVE THE CURRENT INTERACTIVE JOBS IP ADDRESS                */

/*                                                                */

/* SPECIAL COMPILE OPTIONS:                                       */

/*                                                                */

/*           WRITTEN BY: KEN GRAAP 09/23/98                       */

/*           UPDATED BY:                                          */

/*                                                                */

/* ************************************************************** */

             PGM

/* ************************************************************** */

/*                                                                */

/* DECLARE PROGRAM VARIABLES                                      */

/*                                                                */

/* ************************************************************** */

             DCL        &ERRORSW *LGL                     /* Std err */

             DCL        &MSGID *CHAR LEN(7)               /* Std err */
/*                                                                */

/* ************************************************************** */

             PGM

/* ************************************************************** */

/*                                                                */

/* DECLARE PROGRAM VARIABLES                                      */

/*                                                                */

/* ************************************************************** */

             DCL        &ERRORSW *LGL                     /* Std err */

             DCL        &MSGID *CHAR LEN(7)               /* Std err */

             DCL        &MSGDTA *CHAR LEN(100)            /* Std err */

             DCL        &MSGF *CHAR LEN(10)               /* Std err */

             DCL        &MSGFLIB *CHAR LEN(10)            /* Std err */

             DCL        VAR(&DEVD) TYPE(*CHAR) LEN(10)

             DCL        VAR(&IP) TYPE(*CHAR) LEN(15)

             DCL        VAR(&RECEIVER) TYPE(*CHAR) LEN(892)

             DCL        VAR(&LENGTH) TYPE(*CHAR) LEN(4)

             DCL        VAR(&ERRLENGTH) TYPE(*CHAR) LEN(4)

/* ************************************************************** */

/*                                                                */
             DCL        &MSGDTA *CHAR LEN(100)            /* Std err */ 
             DCL        &MSGF *CHAR LEN(10)               /* Std err */ 
             DCL        &MSGFLIB *CHAR LEN(10)            /* Std err */ 
             DCL        VAR(&DEVD) TYPE(*CHAR) LEN(10)                  
             DCL        VAR(&IP) TYPE(*CHAR) LEN(15)                    
             DCL        VAR(&RECEIVER) TYPE(*CHAR) LEN(892)             
             DCL        VAR(&LENGTH) TYPE(*CHAR) LEN(4)                 
             DCL        VAR(&ERRLENGTH) TYPE(*CHAR) LEN(4)              
/* ************************************************************** */    
/*                                                                */    
/* GLOBAL MESSAGE MONITOR                                         */    
/*                                                                */    
/* ************************************************************** */    
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(STDERR1))       
/* ************************************************************** */    
/*                                                                */    
/* RETRIVE THE CURRENT DEVICE IP ADDRESS                          */    
/*                                                                */
/* ************************************************************** */
/*                                                                */ 
/* GLOBAL MESSAGE MONITOR                                         */   
/*                                                                */   
/* ************************************************************** */   
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(STDERR1))      
/* ************************************************************** */   
/*                                                                */   
/* RETRIVE THE CURRENT DEVICE IP ADDRESS                          */   
/*                                                                */   
/* ************************************************************** */   
 

             RTVJOBA    JOB(&DEVD)                                     
             CHGVAR     VAR(%BIN(&LENGTH)) VALUE(892)                  
             CHGVAR     VAR(%BIN(&ERRLENGTH)) VALUE(0)                 
             CALL       PGM(QDCRDEVD) PARM(&RECEIVER &LENGTH +         
                          DEVD0600 &DEVD &ERRLENGTH)                   
             CHGVAR     VAR(&IP) VALUE(%SST(&RECEIVER 878 15))         
             SNDPGMMSG  MSG(&IP)

/* ************************************************************** */ 
/*                                                                */ 
/* NORMAL END OF PROGRAM                                          */ 
/*                                                                */ 
/* ************************************************************** */ 
 END:        RETURN                                                  
/* ************************************************************** */ 
/*                                                                */ 
/* STANDARD ERROR PROCESSING                                      */
                                                                        
/* ************************************************************** */    
/*                                                                */    
/* NORMAL END OF PROGRAM                                          */    
/*                                                                */    
/* ************************************************************** */    
 END:        RETURN                                                     
/* ************************************************************** */    
/*                                                                */    
/* STANDARD ERROR PROCESSING                                      */    
/*                                                                */    
/* ************************************************************** */    
 STDERR1:               /* Standard error handling routine */           
             IF         &ERRORSW SNDPGMMSG MSGID(CPF9999) +             
                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* Func chk */ 
             CHGVAR     &ERRORSW '1' /* Set to fail ir error occurs */  
 STDERR2:    RCVMSG     MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) +  
                          MSGF(&MSGF) MSGFLIB(&MSGFLIB)                 
             IF         (&MSGID *EQ '       ') GOTO STDERR3             
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
/*                                                                */    
/* ************************************************************** */    
 STDERR1:               /* Standard error handling routine */           
             IF         &ERRORSW SNDPGMMSG MSGID(CPF9999) +             
                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* Func chk */ 
             CHGVAR     &ERRORSW '1' /* Set to fail ir error occurs */  
 STDERR2:    RCVMSG     MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) +  
                          MSGF(&MSGF) MSGFLIB(&MSGFLIB)                 
             IF         (&MSGID *EQ '       ') GOTO STDERR3             
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +            
                          MSGDTA(&MSGDTA) MSGTYPE(*DIAG)                
             GOTO       STDERR2 /* Loop back for addl diagnostics */    
 STDERR3:    RCVMSG     MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) +  
                          MSGF(&MSGF) MSGFLIB(&MSGFLIB)                 
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +            
                          MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)              
             ENDPGM

 




Kenneth

--
********************************
        Kenneth E. Graap
  AS/400 Systems Administrator
    NW Natural - Information Services
             System Services
          503 226 4211 X5537
           FAX  503 721 2521
        keg@nwnatural.com
********************************


+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.