the IPv4 LAN address connection should be pretty simple, you don't even need to mess with port forwarding. Just make sure that your security settings allow the connection and remember that this address will likely change regularly.
For the external internet IP, you will need to set up port forwarding. the best way to get everything configured is to log in to your router. The default gateway address is the router and most have a configuration page which can be accessed by entering this ip into a web browser. Unless it's specifically been changed it probably uses a default log in like admin:admin or admin:password
http://portforward.com/help/pfprogression.htm
is a good resource for networking info and getting this sort of thing working, and they have an extensive list of routers and logins.
finally, I put this together back when I was trying to get this stuff figured out. I've never had issues using port 8000 but you can change it to whatever you want. the getIP$() function for getting your external IP came from somewhere on these boards though I forget now who it was from.
I've successfully connected using computers both inside and outside the network with this. get your connectivity working here and you should be able to adapt it to your project.
always active on
set display mode 600,480,32
set window on
sync on
lanConnect as string
wanConnect as string
`windows firewall
if net firewall enabled()=1 then FWstatus=net firewall enable application("iptest.exe","iptest")
sync
print "App allowed by Firewall: ";FWstatus;" getting IPs..."
sync
`get IPs
wanIP$=getIP$()
lanIP$=multiplayer get ip address()
net set port 8000
state=1
do
sync
cls
set cursor 0,0 : print "WAN: "+wanIP$
set cursor 0,20 : print "LAN: "+lanIP$
select state
`select mode
case 1
set cursor 0,40 : print "1-host"
set cursor 0,60 : print "2-connect via LAN"
set cursor 0,80 : print "3-connect via WAN"
set cursor 0,120 : input "Enter mode type: ", mode
if mode>0 then state=2
if mode=2
set cursor 0,140 : input "Enter LAN IP to connect to: ", lanConnect
else
if mode=3
set cursor 0,140 : input "Enter WAN IP to connect to: ", wanConnect
endif
endif
endcase
`initialize connection
case 2
select mode
case 1
set cursor 0,40 : print "Hosting: Attempting to initialize a session."
netstatus=net host(10)
if netstatus=1 then state=3
endcase
case 2
set cursor 0,40 : print "Connecting via LAN: Attempting to connect to a session."
netstatus=net connect(lanConnect)
if netstatus=1
state=3
else
neterror$=net get error()
set cursor 0,60 : print neterror$
endif
endcase
case 3
set cursor 0,40 : print "Connecting via WAN: Attempting to connect to a session."
netstatus=net connect(wanConnect)
if netstatus=1
state=3
else
neterror$=net get error()
set cursor 0,60 : print neterror$
endif
endcase
endselect
endcase
`main
case 3
select mode
case 1
newclient=net player joined()
oldclient=net player left()
clientsnow=net get player amount()
set cursor 0,40 : print "Hosting: #Clients connected= "; clientsnow
endcase
case 2
netstatus=net connected()
if netstatus=1
set cursor 0,40 : print "Connecting via LAN: Connected"
else
neterror$=net get error()
set cursor 0,40 : print "Connecting via LAN: Not Connected"
set cursor 0,60 : print neterror$
endif
endcase
case 3
netstatus=net connected()
if netstatus=1
set cursor 0,40 : print "Connecting via WAN: Connected"
else
neterror$=net get error()
set cursor 0,40 : print "Connecting via WAN: Not Connected"
set cursor 0,60 : print neterror$
endif
endcase
endselect
endcase
endselect
loop
end
function getIP$()
Site$ = "ipcheckit.com"
Request$ = ""
` Connect to the site, and get a response (which will hopefully contain the IP address)
http connect Site$
Result$ = http request data("GET", Request$, "")
` The result, if successful, will contain the IP address surrounded by html bold tags
` So first, search for the opening tag...
Start = instr(Result$, "<b>")
if Start > 0
` If the tag was found, then the IP address starts 3 characters further on.
inc Start, 3
` Search for the closing tag.
Finish = instr(Result$, "</b>", Start)
` Cut out the text between the tags
Result$ = mid$( Result$, Start, Finish - Start )
` Print the result.
print Result$
else
print "Unable to get the IP address"
endif
http disconnect
endfunction Result$
