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 

Java sockets and LUA wlan

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



Joined: 06 May 2007
Posts: 2

PostPosted: Sun May 06, 2007 10:05 pm    Post subject: Java sockets and LUA wlan Reply with quote

Hello!

I've got problems sending strings to a small test-program on my Linux PC from my PSP using LUA socket functions.

on my PSP i've got this code:

Code:

   socket = Socket.connect("192.168.1.4", 4444)
   while not socket:isConnected() do System.sleep(100) end


and then this :
Code:

while true do   
   socket:send("hello")
   screen:print(20,100,"message sent", green)
   screen.flip()
   System.sleep(1000)
      if Controls.read():cross() then
         break end
      end
   
   screen.waitVblankStart(120)
end

on my pc I've got a small java program running sockets:


Code:


import java.net.*;
import java.io.*;

class pspConnect{
   

    public static void main(String[] args) throws IOException
    {
       
        ServerSocket serverSocket = null;
       
        // tries to open socket and exits with error if failed
       
        try
        {
            serverSocket = new ServerSocket(4444, 5 );
           
        }catch (IOException e) {
            System.err.println("could not listen on port: 4444");
            System.exit(-1);
        }
       
     
      //waits for connect and prints "connected" if successful
        Socket incoming = serverSocket.accept();
        if (incoming.isConnected())
        {
            System.out.println("connected");
        }
       

        BufferedReader in = new BufferedReader( new InputStreamReader( incoming.getInputStream()));

        //spits out anything that comes through
        while(true)
        {
           
            System.out.println(in.readLine());
           
           
        }

    }

}



It works as far as to getting a "connected" on my console output on my PC

I've also written this small client and run succesfully it on a separate computer:

Code:

import java.net.*;
import java.io.*;

class pspConnectClient{
   

    public static void main(String[] args) throws Exception
    {
       
        Socket socket;

       
        socket = new Socket("192.168.1.4", 4444);
       
        if(socket.isConnected())
        {
            System.out.println("I'm connected");   
        }
       
        String message;
       
        System.out.print("\ttype something");
       
        message = Keyboard.readString();
       
        PrintStream send = new PrintStream(socket.getOutputStream());
       
        while (true)
        {
            send.println(message);
        }
       
       
    }

}




My server spits out anything I write into this small client, so Java -> Java works OK atleast

I've also tested the psp connecting to Hercules (a tcp testing software) through wine on my linux pc and I receive the "hello" string as expected.

which means that the PSP is in fact communicating with my PC (also proven by me receiving the "connected" message from the java-program).

So why oh why can I not send a string from my PSP to my small socket-program?

thx for help in advance

pixi
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