Localhost (127.0.0.1) is the address of the phone or the emulator.  I
assume that your server program in C is on your devlopment machine.
So you need to connect to your PC's IP address.

You can use ADB
http://developer.android.com/guide/developing/tools/adb.html

to setup port forwarding from the device to your PC.

--
RichardC

On Oct 8, 8:57 pm, Android_n00b <nikhil...@gmail.com> wrote:
> Hi,
>
> I am trying to create a connection between a server socket program
> written in C and an android client socket program. Now when I write a
> regular java client program such as:
>
> try
> {
>         Socket socket = new Socket("localhost", 5554);
>         PrintWriter out = new PrintWriter(echoSocket.getOutputStream
> (), true);}
>
> catch(Exception e)
> {
>               //................}
>
> out.println("Hello World");
>
> This program works perfectly and my server.c file receives the
> message.
> However, when I try the same program with the Android Emulator, I get
> an "Error:java.net.ConnectException: localhost/127.0.0.1:5554 -
> Connection refused" I have tried different ports as well (8888, 3490).
> This works perfectly with the regular Java project, but the moment I
> write the same code in an Android project I get that error. I have
> been stuck on this all day and am really getting frustrated :( Would
> appreciate any help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to