QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Useful LUAPlayer Networking Functions

This is a discussion on Useful LUAPlayer Networking Functions within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hey everyone. I have noticed a couple of errors with the current LUAPlayer. The Wlan.getIPAddress() function does not work When ...

Reply
 
LinkBack Thread Tools
Old 12-10-2005, 09:45 AM   #1
 
joreofiorio35's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 46
Trader Feedback: 0
Exclamation Useful LUAPlayer Networking Functions

Hey everyone. I have noticed a couple of errors with the current LUAPlayer.
  1. The Wlan.getIPAddress() function does not work
  2. When you try to connect to a server using the DNS, or Host name or whatever, it will not work, it has to be an IP Address.
So I have made a function that returns the PSP'S IP Address and a function that converts a DNS name into an IP Address string so you can connect to it w/Socket.connect. These connect to websites that actually do it for you and then it just finds the string of wherever it displays that information and returns it:

Code:
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")
	System.sleep(100)
	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 break end
		screen.waitVblankStart()
		a=a+1
	end
	return -1
end

function GETIPFROMDNS(thedns)
	IP = ""
	a=1
	b=1
	ipgetsock2 = Socket.connect("207.44.246.79", 80)
	while not ipgetsock2:isConnected() do System.sleep(100) end
	bytesSent = ipgetsock2:send("GET /modperl/dnslookup.cgi?domain="..thedns.." HTTP/1.0\r\n")
	bytesSent = ipgetsock2:send("host: www.grsites.com\r\n\r\n")
	thestr=""
	while true do
		thestr = thestr..ipgetsock2:recv()
		if placefound == nil or placefound < 0 then placefound = string.find(thestr, ": <b>") end
		if placefound then placefound=placefound+5
			while true do
		 	if string.sub(thestr, placefound, placefound) == "<" then if IP ~= nil then return IP end end
				IP=IP..string.sub(thestr, placefound, placefound)
				placefound=placefound+1
				if Controls.read():start() then break end
				screen.waitVblankStart()
			end
		end
		a=a+1
		placefound=nil
		screen.waitVblankStart()
	end
	return -1
end
Thanks,
Josh.
__________________
[SIZE=1][CENTER]Some of my accomplishments in the Sonic community:[INDENT][SIZE=1][URL="http://www.s2beta.com/forums/index.php?showtopic=8365"]Sonic in Chaotix (Revision 2)[/URL][/SIZE][SIZE=1]
[URL="http://www.s2beta.com/forums/index.php?showtopic=8116"]Knuckles' Chaotix Art Editor C++ Port[/URL][/SIZE][/INDENT][/CENTER]
[/SIZE]
joreofiorio35 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2005, 09:49 AM   #2
 
z357x's Avatar
 
Join Date: Jun 2005
Location: "Out for Soda"
Posts: 1,362
Trader Feedback: 0
Default

souns cool, I don't now any programing yet though. too bad wifi still won't work in 2.0
__________________
[IMG]http://img.photobucket.com/albums/v465/z357z/Photoshop/BKsig.jpg[/IMG]
z357x is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-11-2005, 10:20 AM   #3
 
simmcity's Avatar
 
Join Date: May 2005
Location: Canada
Posts: 399
Trader Feedback: 0
Default

you should report this to shine and nevyn so they can fix the problem
simmcity is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-11-2005, 10:53 AM   #4
 
Join Date: Dec 2005
Posts: 82
Trader Feedback: 0
Default

what could possibly be done with these networking functions?
Neodudeman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-11-2005, 12:01 PM   #5
 
joreofiorio35's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 46
Trader Feedback: 0
Default

Yes, I acutally have told Shine a while back and pointed out the problem to him. He fixed it right away and said he would release a new release soon.

EDIT: You can do a lot of things with these functions. What if you wanted to connect to your PSP testing a program, but you dont know its IP?? This will display its IP for you. Also for the DNS one, if you wanted to connect to a server, but you only know its dns, then you can connect to it with this function. I have used both of these in my soon to be released PSP CHAT program, and I find them very useful. I just posted these because I thought they might come in handy for some people. :icon_smil
__________________
[SIZE=1][CENTER]Some of my accomplishments in the Sonic community:[INDENT][SIZE=1][URL="http://www.s2beta.com/forums/index.php?showtopic=8365"]Sonic in Chaotix (Revision 2)[/URL][/SIZE][SIZE=1]
[URL="http://www.s2beta.com/forums/index.php?showtopic=8116"]Knuckles' Chaotix Art Editor C++ Port[/URL][/SIZE][/INDENT][/CENTER]
[/SIZE]

Last edited by joreofiorio35; 12-11-2005 at 12:06 PM..
joreofiorio35 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
functions , luaplayer , networking

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 08:47 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us