Java sockets and LUA wlan

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

Moderators: Shine, Insert_witty_name

Post Reply
pixi
Posts: 2
Joined: Sun May 06, 2007 9:36 pm

Java sockets and LUA wlan

Post by pixi »

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: Select all

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

Code: Select all

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: Select all


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: Select all

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
Post Reply