Who's Online 
 
              
          115  user(s) are online (
94  user(s) are browsing 
Forums )
Members: 0
Guests: 115
    more...
  
      
     
   
 
                
        
            
                        
            
                        
  
      
          Topic options 
                           
            
      
          View mode 
                        Newest First 
                 
                      
              
    
         
 
    
  
    
    
        
    
    
        
            
         
        
            How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/11 23:32 
                                  
                                    #1  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        Can anyone give hints on a simple way to find my Amiga's local IP address?
                        
            
                                            
                
                
                    Edited by ChrisH on 2018/6/12 20:26:30
                      
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 0:08 
                                  
                                    #2  
     
    
                
                             Not too shy to talk
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Skærbæk. Denmark
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        well if you want to get the ip addr from a shell you can use my util rIPConfig but if you want to get it from code you can use BSD Socket library
                        
            
                                    
 
     
    
                
                                
                “The best thing about a boolean is even if you are wrong, you are only off by a bit.”
            
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 7:01 
                                  
                                    #3  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @rwo
                        
            
                                    
 
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 7:17 
                                  
                                    #4  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @ChrisH
                        
            
                                    
 
     
    
                
                                
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 12:56 
                                  
                                    #5  
     
    
                
                             Not too shy to talk
                         
                    
                        Joined: Last Login
                                : 
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        Type shownetstatus command to shell window?
                        
            
                                    
 
     
    
                
                             
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 18:38 
                                  
                                    #6  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Lyon, France
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        Yes : c:shownetstatus
                        
            
                                    
 
     
    
                
                                
                --
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 18:46 
                                  
                                    #7  
     
    
                
                             Just popping in
                         
                    
                        Joined: Last Login
                                : 
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        He meant from own program code
                        
            
                                    
 
     
    
                
                             
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 20:27 
                                  
                                    #8  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @all
                        
            
                                            
                
                
                    Edited by ChrisH on 2018/6/12 20:59:58
                      
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 22:37 
                                  
                                    #9  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @ChrisH
Quote:
This bit of teh autodoc is what you missed 
Quote:
            
                                    
 
     
    
                
                                
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/12 22:39 
                                  
                                    #10  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Finland, the land of Santa, sauna, sisu and salmiakki
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @ChrisH
struct  List * netiflist = NULL ;
 struct Node  * node = NULL ;
 struct sockaddr addr ;
 int32 res = 0 ;
 SocketBase =( struct Library  *) IExec -> OpenLibrary ( "bsdsocket.library" , 0 );
 SocketBase != NULL )
 ISocket =( struct SocketIFace  *) IExec -> GetInterface ( SocketBase , "main" , 1 , NULL );
 ISocket != NULL )
 netiflist = ISocket -> ObtainInterfaceList ();
 netiflist != NULL )
 node = IExec -> GetHead ( netiflist );
 node != NULL )
 node != NULL )
 node -> ln_Name != NULL )
 printf ( "Network interface %s:\\n" , node -> ln_Name );
 // QueryInterfaceTags returns 0 for success, -1 for error
 res = ISocket -> QueryInterfaceTags ( node -> ln_Name ,
 IFQ_Address ,& addr ,
 TAG_DONE );
 res == 0 )
 printf ( "IP: %u.%u.%u.%u\\n" ,( uint8 ) addr . sa_data [ 2 ],( uint8 ) addr . sa_data [ 3 ],( uint8 ) addr . sa_data [ 4 ],( uint8 ) addr . sa_data [ 5 ]);
 printf ( "- Error: Can't query information (%ld)\\n" , res ); }
 node = IExec -> GetSucc ( node );
 printf ( "No network interfaces found\\n" );
 ISocket -> ReleaseInterfaceList ( netiflist );
 IExec -> DropInterface (( struct  Interface *) ISocket );
 IExec -> CloseLibrary ( SocketBase );
  
Edit: Added while loop to the code.
            
                                            
                
                
                    Edited by TSK on 2018/6/14 18:53:50
                      
     
    
                
                                
                Rock lobster bit me - so I'm here forever
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/13 18:01 
                                  
                                    #11  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @broadblues
                        
            
                                    
 
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/13 18:05 
                                  
                                    #12  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @TSK
Your code (probably) answers my next question, which would have been:
Quote:
Is it a good idea to only use the first Network Interface returned by ObtainInterfaceList() ? Although I suppose if you were being really picky, you'd interate through all the Network Interfaces until you got an IP Address.  (I'm assuming QueryInterfaceTagList() will fail if the network interface has no IP address - I guess you'd need to test that as well. edit: Seems that ObtainInterfaceList() returns an empty list in that case.)
            
                                            
                
                
                    Edited by ChrisH on 2018/6/13 19:09:45
                      
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address?
         
        
            
                                    Posted on: 
2018/6/14 18:55 
                                  
                                    #13  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Finland, the land of Santa, sauna, sisu and salmiakki
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @ChrisH
                        
            
                                    
 
     
    
                
                                
                Rock lobster bit me - so I'm here forever
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/15 12:36 
                                  
                                    #14  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Adelaide, Australia
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        The ShowNetStatus source code is available in the Roadshow SDK if it's of any help.
                        
            
                                    
 
     
    
                
                             
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/16 10:27 
                                  
                                    #15  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Lyon, France
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @ChrisH
a TCP/IP module soon to be available? 
            
                                    
 
     
    
                
                                
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/17 14:03 
                                  
                                    #16  
     
    
                
                             Home away from home
                         
                    
                        Joined: Last Login
                                : 
                                                    From  England
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @Elwood
PortablE has had TCP/IP support for years (but only for AmigaOS4)...
Otherwise I wouldn't have been able to write this:
http://cshandley.co.uk/enewsreader/ 
            
                                    
 
     
    
                
                                
                Author of the 
PortablE  programming language.
            
 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/24 23:35 
                                  
                                    #17  
     
    
                
                             Just popping in
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Bettendorf, IA, USA
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        How do you get the default gateway and DNS's?
                        
            
                                    
 
     
    
                
                                
                Workbench Explorer - A better way to browse drawers
            
                 
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/25 11:33 
                                  
                                    #18  
     
    
                
                             Just can't stay away
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Donostia (SPAIN)
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @mritter0
                        
            
                                    
 
     
    
                
                             
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/25 17:04 
                                  
                                    #19  
     
    
                
                             Just popping in
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Bettendorf, IA, USA
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        @jabirulo
                        
            
                                    
 
     
    
                
                             
     
    
        
     
     
   
        
  
    
    
        
    
    
        
            
         
        
            Re: How to get my local IP address? (using program code)
         
        
            
                                    Posted on: 
2018/6/25 19:14 
                                  
                                    #20  
     
    
                
                             Just popping in
                         
                    
                        Joined: Last Login
                                : 
                                                    From  Bettendorf, IA, USA
                                                                            Group: 
                                 
                                                
                                                                            
                                             
                                     
        
                        Got it.  Thanks.
                        
            
                                    
 
     
    
                
                                
                Workbench Explorer - A better way to browse drawers
            
                 
     
    
        
     
     
   
    
  
    
      Currently Active Users Viewing This Thread:
      1
      (
        0 members
                  and 1 Anonymous Users
              )