Pls help..

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Swissidle
Posts: 16
Joined: Thu Jan 29, 2009 12:37 am

Pls help..

Post by Swissidle »

I need help

http://www.psp-programming.com/animate/wlan.rar

i tested this sample to download using libcurl and it works fine. My question is: is it possible to use this function/eboot inside my lua application? if not.. can someone help me how to convert this c sourcecode into lua script?

Code: Select all

graphicsPrintln("connecting to www.luaplayer.org...")
socket, error = Socket.connect("www.luaplayer.org", 80)
while not socket:isConnected() do System.sleep(100) end
graphicsPrintln("connected to " .. tostring(socket))

-- send request
graphicsPrintln("loading test page...")
bytesSent = socket:send("GET /wlan-test.txt HTTP/1.0\r\n")
bytesSent = socket:send("host: www.luaplayer.org\r\n\r\n")

-- read and display result
requestCount = 0
header = ""
headerFinished = false
while true do
	-- read from test page
	buffer = socket:recv()
	if string.len(buffer) > 0 then 
		if headerFinished then
			graphicsPrint(buffer)
		else
			header = header .. buffer
			startIndex, endIndex = string.find(header, "\r\n\r\n")
			if endIndex then
				graphicsPrint(string.sub(header, endIndex))
			end
		end
	end
	
	-- check for incoming requests
	incomingSocket = serverSocket:accept()
	if incomingSocket then
		-- send test page back and close socket
		requestCount = requestCount + 1
		incomingSocket:send("HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n")
		incomingSocket:send("Testpage from your PSP.\r\n")
		incomingSocket:send("This was request number " .. requestCount .. ". Reload to increment it.")
		incomingSocket:close()
	end
	if Controls.read():start() then break end
	screen.waitVblankStart()
end
using this sample code from luaplayer, is there a way that i can save the file from http to my memory stick?

thanks.
<><><><><>>>NOOB<><><><><<>
Post Reply