forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sockets with PSP/Lua

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
LordCthulu



Joined: 29 Dec 2005
Posts: 11

PostPosted: Thu Dec 29, 2005 12:36 am    Post subject: Sockets with PSP/Lua Reply with quote

I finally checked out Shine's WLan script, and edited it to retrieve a file off my own webserver.

Anyway...in short I was curious if it's possible to connect the PSP to a computer, by having the PSP run a lua script (say as a client) and trying to connect to the computer who is running a server specifically for the PSP.
I tried but failed :S I used an old server I made in C++/WinSock and tried editing the WLan file, but couldn't get it to work.

It's probably something I did wrong or am not seeing, but anyone have any ideas why it wouldn't work? Limited functionality on Luaplayer or something like that perhaps..? Anyways thanks a lot for the help :)
Back to top
View user's profile Send private message
LiquidIce



Joined: 04 Apr 2005
Posts: 55

PostPosted: Thu Dec 29, 2005 1:55 am    Post subject: Reply with quote

Hey,

Not sure if this helps, but I've got Lua talking to my web server via HTTP Post calls. Here is some code that does the POSTing:

Code:


function sendToWebserver(text)
      length = string.len(text)
      socket, error = Socket.connect("192.168.1.50", 80)
      while not socket:isConnected() do System.sleep(100) end
      bytesSent = socket:send("POST /RPC HTTP/1.1\r\n")
      bytesSent = socket:send("Content-Type: application/x-www-form-urlencoded\r\n")
      bytesSent = socket:send("Content-Length: "..length.."\r\n")
      bytesSent = socket:send("\r\n")
      bytesSent = socket:send(text.."\r\n\r\n")
      closeIt = socket:close()
end


sendToWebserver("method=TriggerEventByName&Param1=systemStartup&Param2=0&Param3=0&Param4=0")



Just replace /RPC with the path and filename to your PHP, ASP, or other web script, and you can now send multiple variables from the psp to the webserver.

I'm still working on getting the response and parsing it to display useful data on the screen. But for my purposes right now I only need to issue commands from the PSP to the webserver. For those curious, I'm using the PSP as a controller for something. This time it's not my home... You'll have to wait until Jan 5th to find out what it is.
Back to top
View user's profile Send private message Visit poster's website
LordCthulu



Joined: 29 Dec 2005
Posts: 11

PostPosted: Thu Dec 29, 2005 2:56 am    Post subject: Reply with quote

^^; Thanks for the help, but right now im stuck at trying to actually connect.
I tried using port 7654, and tried using 192.168.1.101 and 68.*.*.* but no luck :S

Anyone know if it has to be port 80? Or maybe has to be a webserver? :S
Back to top
View user's profile Send private message
LiquidIce



Joined: 04 Apr 2005
Posts: 55

PostPosted: Thu Dec 29, 2005 10:24 am    Post subject: Reply with quote

It should not need to be a webserver, although the above code is specific to an HTTP connection.

A good way to test and make sure your communicating is to use a telnet server program. I use this one called Hercules all the time:

http://www.hw-group.com/products/hercules/index_en.html

Just start up the TCP server, set the port and then try to connect to it from your PSP.

Also, make sure you are using the correct WLAN connection. That caused some confusion for me. The LAST WLAN connection you create is numbered 0 when you activate the wlan adapter.
Back to top
View user's profile Send private message Visit poster's website
n00b32



Joined: 05 Sep 2006
Posts: 7

PostPosted: Tue Sep 05, 2006 10:12 am    Post subject: Reply with quote

doh I made an app in delphi in 5 minutes to wich the psp sent the du,p from irda.... 5minutes :) and it worked. now I'm stuck trying to make an updater for my chat. how to know where the http ends and data begins ... maybe I'll add a --beginlua line at the start of the script and then search it xD yup good ide
//away xD
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group