[RESOLVEDHow to access to an opened socket on the emulator ?

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

[RESOLVEDHow to access to an opened socket on the emulator ?

Postby Vermouth » Wed Apr 15, 2009 2:13 pm

Hello!

I try to access to a socket opened on the emulator but i not find how to !

Code runing on the emulator:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. try{
  2.  
  3.                         ServerSocket ss = new ServerSocket(8888);
  4.  
  5.                         while(true) {
  6.  
  7.                                 Socket s = ss.accept();
  8.  
  9.                                 PrintWriter pw = new PrintWriter(s.getOutputStream());
  10.  
  11.                                 pw.println("HTTP/1.1 200");
  12.  
  13.                                 pw.println("Content-type : text/html\n");
  14.  
  15.                                 pw.println("<html>Hello !!</html>");
  16.  
  17.                                 pw.close();
  18.  
  19.                         }
  20.  
  21.                 }
  22.  
  23.                 catch(IOException e) {}
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Runing this code in a java programme work, i can see "Hello !!" in my brrowser at http://localhost:8888/
But this not work with the emulator!

I try lot of thing but nothing work :/ !

How to do this ?

Thank !
Last edited by Vermouth on Thu Apr 16, 2009 12:58 pm, edited 1 time in total.
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Top

Postby padde » Wed Apr 15, 2009 2:18 pm

Try your IP instead of localhost.. that worked for me.

Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Vermouth » Wed Apr 15, 2009 2:25 pm

"Conection failed"

But with localhost, firefox is waiting for response (loading page indefinitely).

I already try ip like 10.0.2.x... (see in doc)
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Postby Vermouth » Wed Apr 15, 2009 5:23 pm

no idea ?!?
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Postby Vermouth » Wed Apr 15, 2009 6:01 pm

Redirecting tcp port in the emulator (redir add tcp:8888:8888) allow telnet to conect at localhost:8888.

But the programme don't continue, probably nothing is print !

I can connect but the programme stop on the instruction "ss.accept();" :/ !
If i close the programme, telnet show "Connection closed by foreign host."

Strange...
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Postby Vermouth » Thu Apr 16, 2009 11:08 am

Solution:
-Make this redirection: tcp:8888:8888 and udp:8888:8888
-Go to http://localhost:8888/

I don't know if possible that i didnt't try this yet lol !

PS:I hope you understand what i said looool !!
/!\ Bad English Speaker /!\
Tell me if a sentence is not corect :P
Vermouth
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 15, 2009 2:01 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests