I checked out the link you provided and found that I needed to use the
IP address 10.0.2.2 to access the host's loopback interface.  I
changed my request to us that IP and it works like a champ.

Thanks much!

On Sep 21, 12:28 pm, Kumar Bibek <[email protected]> wrote:
> Check if your server is responding or not.
>
> You should probably look at the "Network Space Address" on this 
> page.http://developer.android.com/guide/developing/tools/emulator.html
>
> -Kumar Bibekhttp://techdroid.kbeanie.com
>
> On Sep 22, 12:18 am, John Gaby <[email protected]> wrote:
>
> > Thanks for the reply.  I have tried using the IP address of the host
> > machine like this:
>
> > String urlServer = "http://192.168.1.101:3571/mycmd.aspx?
> > command=test";
>
> > but when I do that, my program times out on the
> > 'connection.getOutputStream' call.  I am also not sure I see how this
> > would work anyway, since I an not able to access my local server by
> > using that IP address, even from a browser.
>
> > Thanks
>
> > On Sep 21, 11:22 am, Hotouch <[email protected]> wrote:
>
> > > if you are testing this on your emulator then you have to change
> > > localserver to your ip because emulator is it self a localserver.
>
> > > open your cmd and write "ipconfig/all" tp get your system ip and then
> > > place your ip instead of localhost and it should work this time :)
>
> > > Thanks
>
> > > On Sep 21, 10:11 pm, John Gaby <[email protected]> wrote:
>
> > > > I am trying to do an HTTP POST of some data.  The following is a test
> > > > routine that I wrote to try and accomplish this:
>
> > > >         void Put()
> > > >         {
> > > >                 HttpURLConnection connection = null;
> > > >                 DataOutputStream outputStream = null;
>
> > > >                 String urlServer = 
> > > > "http://localhost:3571/mycmd.aspx?command=test";;
> > > >                 String message = "This is a message";
>
> > > >                 try
> > > >                 {
> > > >                         URL url = new URL(urlServer);
> > > >                         connection = (HttpURLConnection) 
> > > > url.openConnection();
>
> > > >                         // Allow Inputs & Outputs
> > > >                         connection.setDoInput(true);
> > > >                         connection.setDoOutput(true);
> > > >                         connection.setUseCaches(false);
>
> > > >                         // Enable POST method
> > > >                         connection.setRequestMethod("POST");
>
> > > >                         connection.setRequestProperty("Connection", 
> > > > "Keep-Alive");
> > > >                         connection.setRequestProperty("Content-Type", 
> > > > "application/octet-
> > > > stream");
>
> > > >                         outputStream = new
> > > > DataOutputStream( connection.getOutputStream() );
> > > >                         outputStream.writeBytes(message);
>
> > > >                         // Responses from the server (code and message)
> > > >                         int serverResponseCode = 
> > > > connection.getResponseCode();
> > > >                         String serverResponseMessage = 
> > > > connection.getResponseMessage();
>
> > > >                         outputStream.flush();
> > > >                         outputStream.close();
> > > >                 }
> > > >                 catch (Exception ex)
> > > >                 {
> > > >                         int i = 0;
> > > >                 //Exception handling
> > > >                 }
> > > >         }
>
> > > > If I set urlServer to 'localhost' I get an exception:
>
> > > > java.net.ConnectException: localhost/127.0.0.1:3571 - Connection
> > > > refused
>
> > > > I am presuming that this is because the localhost is not being
> > > > resolved properly to my host machine (I am running under the
> > > > emulator).  Is there a way to access a localhost server on my host
> > > > machine from the emulator, or do I need a real IP address?
>
> > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to