IP Configuration

From QB64.org wiki
Jump to: navigation, search

There are two IP addresses that you may need to Host a session.


Local IP Address: The following function will return your local IP address.

PRINT GetLocalIP$ FUNCTION GetLocalIP$ SHELL _HIDE "cmd /c ipconfig > IPconfig.tmp" OPEN "IPconfig.tmp" FOR INPUT AS #1 DO LINE INPUT #1, ipline$ IF LEFT$(LTRIM$(ipline$), 2) = "IP" THEN CLOSE #1 GetLocalIP$ = MID$(ipline$, INSTR(ipline$, ":") + 1) KILL "IPconfig.tmp" 'kill the messenger? EXIT DO END IF LOOP UNTIL EOF(1) END FUNCTION

Code courtesy of Unseen Machine
Note: If the file is not found use "CMD /C ipconfig > IPconfig.tmp" command line on some systems!


Global IP Address: You need to supply this address to have others connect to you as Host.

PRINT HostAddress$ FUNCTION HostAddress$ Host = _OPENHOST("TCP/IP:319") HostAddress$ = _CONNECTIONADDRESS(Host) END FUNCTION

Warning! This procedure may be blocked by your Firewall or need your permission to be completed!
If you get an address like 127.0.0.1 the firewall is blocking the access!
If you find this to be a problem with others using QB64 please report it at the forum!


Your Clients may need your latest Global IP Address as a Host if your server assigns you a dynamic address that changes!
You can also use WGET to get your global connection address from http://checkip.dyndns.com/


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page