Results 1 to 3 of 3

Thread: Java sockets and LUA wlan

  
  1. #1
    pixi is offline -Hacks Newbie
    Join Date
    May 2007
    Posts
    3
    Rep Power
    0

    Default

    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


  2. #2
    pirata nervo is offline Programmer -Hacks Titan
    Join Date
    Mar 2007
    Posts
    5,529
    Rep Power
    18

    Default

    Wrong section! :rolleyes: go to: http://www.psp-hacks.com/forums/viewforum.php?id=15
    Console Addicted - The news about your console, every day!
    Console Addicted Forums

  3. #3
    pixi is offline -Hacks Newbie
    Join Date
    May 2007
    Posts
    3
    Rep Power
    0

    Default

    mokie dokie :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •