Visual Basic Core Snippet Routines
inet_ntoa
          
                 
   Converts an (Ipv4) Internet network address to an ASCII string representing the address in ".'' (dot) notation as in "192.168.1.100''.  This string resides in memory allocated and is only guaranteed to be valid until the next Windows Sockets function call within the same thread. Therefore, the data should be copied to a local variable before making subsequent Windows Socket calls.           
           Updated:   Monday December 26, 2011   
click to copy code:  



   Applies to:   VB4-32, VB5, VB6   
OS restrictions:   None  
 Code Snippet
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function inet_ntoa Lib "wsock32.dll" _
  (ByVal addr As Long) As Long

Private Declare Function lstrcpyA Lib "kernel32" _
  (ByVal RetVal As String, _
   ByVal Ptr As Long) As Long
                        
Private Declare Function lstrlenA Lib "kernel32" _
  (lpString As Any) As Long
         

Private Function GetInetStrFromPtr(Address As Long) As String
  
   GetInetStrFromPtr = GetStrFromPtrA(inet_ntoa(Address))

End Function


Private Function GetStrFromPtrA(ByVal lpszA As Long) As String

   GetStrFromPtrA = String$(lstrlenA(ByVal lpszA), 0)
   Call lstrcpyA(ByVal GetStrFromPtrA, ByVal lpszA)
   
End Function

 Calling Syntax
  sIpAddrStringOut = GetInetStrFromPtr(dwIpAddrLongIn)

 Comments / Related
demo in use:   GetIpAddrTable: IP Address Table of the Local Machine
GetNetworkParams: Determine Current and Available DNS Servers
GetTcpTable: Local Machine TCP Connection Table
  
Related:   inet_addr   

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter