My application tries to open a socket to a remote (ie. out on the
internet) server but fails with an "Unknown host" exception. I've
simplified the code and plugged it into HelloAndroid as follows:
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
openSocket("www.google.com", 80);
} catch (IOException e) {
e.printStackTrace();
}
}
private Socket sock;
private void openSocket(String host, int port) throws IOException
{
InetAddress inet = InetAddress.getByName(host); // exception
raised here
sock = new Socket();
sock.connect(new InetSocketAddress(inet, port), 3000);
}
}
As the emulator's web browser can connect to www.google.com
successfully I assume my network configuration is correct. I even
disabled the firewall on my development machine but to no avail.
BTW my application will connect to a different server and port - I'm
just using google.com & 80 as an example.
All help appreciated.
richard.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---