Wlan.getIPAddress() function not working
Moderators: Shine, Insert_witty_name
-
- Posts: 6
- Joined: Sat Dec 03, 2005 10:30 am
Wlan.getIPAddress() function not working
Has anybody got this function to work? I am coding a chat program in LUA and I need to tell the user what IP Address his PSP is so other users can connect to him. Yesterday this was coming up with errors saying, "Invalid IP Address." And today it is coming up as a bunch of jumbled up text when I try to print the string that it returns. Shine, have you looked into this?
Re: Wlan.getIPAddress() function not working
Yes, I have the same problem, see my comment in the Applications/WLAN program. I don't know how to fix it.joreofiorio35 wrote:Shine, have you looked into this?
Re: Wlan.getIPAddress() function not working
I think maybe you're not waiting long enough for the Apctl connection to stabilise. Take a look at the code around sceNetApctlGetState() in PspPet's wifi sample code.Shine wrote:Yes, I have the same problem, see my comment in the Applications/WLAN program. I don't know how to fix it.joreofiorio35 wrote:Shine, have you looked into this?
It would be easy enough to test this by putting a large sleep between initialising the wifi and getting the IP address.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
The PSP Homebrew Database needs you!
-
- Posts: 6
- Joined: Sat Dec 03, 2005 10:30 am
Actually shine, I think you have made an error in your coding.
Here is what PspPet has:
And here is what you have Shine:
I think you should change the "!=0" to "==0", because if it doesnt equal zero, then it IS a valid IP address.
Here is what PspPet has:
Code: Select all
if (sceNetApctlGetInfo(8, szMyIPAddr) != 0)
strcpy(szMyIPAddr, "unknown IP address");
Code: Select all
if (sceNetApctlGetInfo(8, szMyIPAddr) != 0) {
// TODO: gets garbage
lua_pushstring(L, szMyIPAddr);
return 1;
}
Agreed. Both fixes are required for complete stability, I think.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
The PSP Homebrew Database needs you!
-
- Posts: 6
- Joined: Sat Dec 03, 2005 10:30 am
Thanks, I've fixed it. Fanjita wants to change something more for testing his 2.00 bootloader and I want to add some more true type font functions (you can set a transformation matrix for rotating and scaling the font and I think there is something for bold fonts), and UDP support is still missing, but then perhaps I'll release a new version this weekend.
-
- Posts: 6
- Joined: Sat Dec 03, 2005 10:30 am
I have another way of getting your IP as of right now, this one will only get your router's IP which you can access your PSP through by port forwarding whichever port your program uses to listen with. This just connects a site and gets the IP from that site by picking apart the string of HTML code.
Code: Select all
function GETIPADDRESS()
thestr = {}
IP = ""
a=1
b=1
ipgetsock, error = Socket.connect("216.99.213.74", 80)
while not ipgetsock:isConnected() do System.sleep(100) end
bytesSent = ipgetsock:send("GET /ipaddress.html HTTP/1.0\r\n")
bytesSent = ipgetsock:send("host: ww1.nia-nia.com\r\n\r\n")
while true do
thestr[a] = ipgetsock:recv()
if placefound == nil then placefound = string.find(thestr[a], "REMOTE_ADDR=") end
if placefound then placefound=placefound+12
while true do
if string.sub(thestr[a], placefound, placefound) == "R" then IP=string.sub(IP, 1, string.len(IP)-1) return IP end
IP=IP..string.sub(thestr[a], placefound, placefound)
placefound=placefound+1
end
end
placefound=nil
if Controls.read():start() then screen.waitVblankStart(10) break end
screen.waitVblankStart()
a=a+1
end
return -1
end