Can not connect lo localhot from emulator using socket

by Oskeol » Fri, 09 May 2008 16:01:35 GMT

Sponsored Links
I want to access an Eccho server in localhost.

Here is the Echo server in localhost

import java.util.Scanner;

public class EchoServer
        public static void main(String[] args)
                        ServerSocket s = new ServerSocket(8189);
                        Socket incoming = s.accept();

                                InputStream inStream   = 
                                OutputStream outStream = 
                                Scanner in = new Scanner(inStream);
                                PrintWriter out = new PrintWriter(outStream, 
                                out.println("Hello! Enter BYE to exit");

                                boolean done = false;

                                while(!done && in.hasNextLine())
                                        String line = in.nextLine();
                                        out.println("Echo: "+ line);
                                                done = true;


                catch(IOException e)


I have a client, on the emulatot that tries to connect to this server.
I use to connect to localhost, but it doesn't work.

Socket s = new Socket("", 8189);

Can anybody explain why this happen,


Can not connect lo localhot from emulator using socket

by kobica » Mon, 12 May 2008 17:15:56 GMT


have you tried to forward/redirect ports?
Maybe that is what you are missing.

Plus, take a look at:

Sponsored Links

Can not connect lo localhot from emulator using socket

by Oskeol » Tue, 13 May 2008 20:31:26 GMT

 Thanks, very much for your help.
Forwarding ports it does now work.

Thnx agani Kobi,


Other Threads

1. Create a wav file and stock this into a data storage with Content Providers

How can I take:  "Create a wav file and stock this into a data storage
with Content Providers"

I try to use the same thing like the following exemple:

with a Bitmap:

import android.provider.MediaStore.Images.Media;
import android.content.ContentValues;

// Save the name and description of an image in a ContentValues map.
ContentValues values = new ContentValues(3);
values.put(Media.DISPLAY_NAME, "road_trip_1");
values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
values.put(Media.MIME_TYPE, "image/jpeg");

// Add a new record without the bitmap, but with the values just set.
// insert() returns the URI of the new record.
Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,

// Now get a handle to the file for that record, and save the data
into it.
// Here, sourceBitmap is a Bitmap object representing the file to save
to the database.
try {
    OutputStream outStream = getContentResolver().openOutputStream
    sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
} catch (Exception e) {
    Log.e(TAG, "exception while writing image", e);

So I think is too similar but I'm really lose !!

Firstly I don't find how to create my File with my byte[].

I try to make that:

    byte[] decoded = Base64.decode( tabMsg[0].getMsgBase64() );

            ContentValues values = new ContentValues();
            values.put(Media.DISPLAY_NAME, "Voicemail1");
            values.put(Media.MIME_TYPE, "Audio/wav");

            Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,

            File m_wav = new File(uri.getEncodedPath(), "voicemail1.wav");

                OutputStream outStream = getContentResolver().openOutputStream
            catch (Exception e)
                Log.e(TAG, "Exception while writing audio", e);

Could you light me, please ??
What are you thinking about my little code and how can I
continuous ???

It's very hard to use the better arguments or parametres with:
values.put(...) and with : getContentResolver().insert(..)

Maybe I have to create my own Content Providers but I think is too
compicated !


2. unable to download youtube video's in android


I am using youtube downloader to download videos.

Suddenly, from today, its not downloading,

it reports,

"D/YTDownload(  740): Got content - parsing...
D/YTDownload(  740): Exception in finding ID: java.lang.Exception: Could not
find download URL or title."

Also, i noticed, in new site, the option to choose from
"Browser or Youtube" is not shown.

Only, i have to select old site or goto desktop version, only then it shows.

Is there any way to download youtube videos or youtube player is available.

I am totally struck with the things.
Any help would be useful.

Thanks and Regards,


3. How to force the on-screen keyboard on HTC Hero

4. Unable to start service intent service not found

5. Why pay Google?

6. how can i MapView my map before attach to window

7. How to use apache commons in my android application