INTERNET

by Mitch » Thu, 20 Aug 2009 14:20:18 GMT


Sponsored Links
 I would like to play around with sockets to see if I can get them to
work, but I'm not having any luck.  Here's what I tried:

new Socket("www.google.com", 80);

I've also tried

new Socket("localhost", 7);

but anything you can suggest that's simple is appreciated.  I'm no
socket expert so I'm not sure if these are considered simple
examples.

I read that I should add INTERNET permission to my manifest, so I did
this too:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://schemas.android.com/apk/res/android" ;
      package="com.kea"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".ServSock"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
</manifest>

I'm just trying to learn so there's no real goal, just looking for a
simple example that I can get working.  Any hints what I'm missing?
Thanks.


--~--~---------~--~----~------------~-------~--~----~



INTERNET

by John P. » Thu, 20 Aug 2009 23:23:52 GMT


 I don't think you want to use sockets if the receiving end isn't setup
to listen for them (in your case of www.google.com).  If you want to
communicate with http protocol, use a Http class.  It may be possible
to build your own HTTP reader using sockets, but there's already one
available from standard Java SDK.

The second attempt to communicate with localhost also needs a
receiving listener to work.  Also if you are using an emulator to
access your hosting computer, use 10.0.2.2 (see
 http://developer.android.com/guide/appendix/faq/commontasks.html #localhostalias).



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


INTERNET

by Roman ( T-Mobile USA) » Fri, 21 Aug 2009 05:54:21 GMT


 It really depends on what you are trying to accomplish. If you want to
implement an application simple application using sockets you can try
so setup a server on your desktop and execute the following commands
from the Android device

                Socket s = new Socket("<IP address of server", <port
on desktop>);
                PrintWriter out = new PrintWriter(s.getOutputStream(),
true);
                out.println("Hello World");


The server should listen on the port you have specified in your
Android app. If you don't want to implement any server you also can
download netcat. It is a very powerful TCP/IP testing tool.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



--~--~---------~--~----~------------~-------~--~----~



INTERNET

by Roman ( T-Mobile USA) » Fri, 21 Aug 2009 06:05:23 GMT


 It really depends on what you are trying to accomplish. If you want to
implement a simple application using sockets you can try
so setup a server on your desktop and execute the following commands
from the Android device

                Socket s = new Socket("<IP address of server", <port
on desktop>);
                PrintWriter out = new PrintWriter(s.getOutputStream(),
true);
                out.println("Hello World");

The server should listen on the port you have specified in your
Android app. If you don't want to implement any server you also can
download netcat. It is a very powerful TCP/IP testing tool.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



--~--~---------~--~----~------------~-------~--~----~



INTERNET

by Mitch » Fri, 21 Aug 2009 11:52:29 GMT


 I'm not trying to use HTTP, the "www.google.com" was just a URL I knew
would be able to respond.  Turns out that if I replace the
"www.google.com" with it's IP "74.125.53.105" then it works.  Don't
know why.

I would like to get 2 android simulators talking so I can test 2 way
communications with data.  I haven't found out how to get 2 simulators
up yet either.



--~--~---------~--~----~------------~-------~--~----~



INTERNET

by Roman ( T-Mobile USA) » Sat, 22 Aug 2009 02:08:52 GMT


 If you use an emulator try to set your DNS when you start the emulator

./emulator -dns-server <ip-address>

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. USB Devices with multiple modes (flip-flop/Zero-CD)

Im dealing with a USB 3G Modem that has a flip-flop/Zero-CD mode. Its
showing me the device as a scsi cdrom but it should show 4 usb ports.

How do i change the devices mode? Normally we'd use USB_modeswitch but
i dont think thats possible since there is no udev or libusb
(..normally) and other things that usbmodeswitch needs.

Does the android kernel use anything similar to udev?

Thanks people!

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag ?

have u try to put this line after defining intent.
 browserIntent .setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);





> 

3. Missing RELAXNG SchemaFactory Implementation?

4. Memory leak in native code using DDMS

5. Listbox displayed only as combobox in webview

6. How to market a map overlay?

7. enable / disable orientation changes at runtime...