Code archives/Networking/BlitzMax ConvertIP function
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This function will convert a string IP something like "127.0.0.1" to its integer equivalent. The original Blitz3d function was created by Perturbatio | |||||
Function ConvertIP:Int( sIPAddress:String ) 'pass IP as a String e.g. "127.0.0.1" 'VARS Local iIP:Int Local iDotPos:Int = 0 Local iOldDotPos:Int = 0 Local strTemp:String Local Counter:Int = 3 'MAIN While Counter > 0 iOldDotPos = iDotPos iDotPos = Instr(sIPAddress, ".", iOldDotPos+1) strTemp = Mid(sIPAddress,iOldDotPos + 1, (iDotPos - iOldDotPos)-1) iIP = iIP + (Int( strTemp ) Shl (Counter * 8)) Counter = Counter - 1 Wend strTemp = Right(sIPAddress, (Len(sIPAddress) - iDotPos) ) iIP = iIP + (Int( strTemp ) Shl 0) Return iIP End Function |
Comments
| ||
Local IP = HostIP("127.0.0.1") ?? |
| ||
This will convert ANY ip address |
Code Archives Forum