Ooops
October 17, 2021, 10:42:04

Author Topic: [bmx] Get PC's local IP address by BlitzSupport [ 1+ years ago ]  (Read 1440 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Get PC's local IP address
Author : BlitzSupport
Posted : 1+ years ago

Description : Just a quickie that returns a string containing your PC's local (LAN) IP address, eg. mine returns "192.168.0.2".

Code :
Code: BlitzMax
  1. Function LocalIP:String ()
  2.         Return DottedIP (HostIp ("", 0))
  3. End Function
  4.  
  5. Print LocalIP ()


Comments :


BlitzSupport(Posted 1+ years ago)

 Updated to handle erroneous result when non-localhost domains have been redirected to 127.0.0.1 via HOSTS file; thanks to _PJ_!


Captain Wicker (crazy hillbilly)(Posted 1+ years ago)

 Works on OSX 10.8.2Returned my iMac/server IP address just fine. 192.168.1.100


_PJ_(Posted 1+ years ago)

 James, Have you tried leaving the HostIP blank to default to the Local Machine?(Sorry B3d code, I HOPE it should still operate for BMax, similar commands at least...
Code: [Select]
Function LocalIP$()
n=CountHostIPs("")
sIP$=HostIP(1)
Return DottedIP(sIP)
End Function

Print LocalIP$()




_PJ_(Posted 1+ years ago)

 .


BlitzSupport(Posted 1+ years ago)

 Thanks, PJ -- I had to edit that a little bit, but this seems to work on my XP install:
Code: [Select]
Function LocalIP:String ()
ip = HostIp ("", 0)
Return DottedIP (ip)
End Function

Print LocalIP$()
I'll try it on my Windows 7 setup later and update the code it if works.


BlitzSupport(Posted 1+ years ago)

 That works on my XP/Win7 PC and my separate Win7 PC, so updated main code.


_PJ_(Posted 1+ years ago)

 Good to know! :) [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal