Pretty standard there too - see the java.net package: http://code.google.com/android/reference/java/net/package-summary.html.
One thing to keep in mind is, if you are trying to connect to your localhost for testing, say another process running locally - you have to keep in mind that the emulator is running there too, so you can't use "localhost" or "127.0.0.1." Use the non loopback IP of your host for that type testing. Here is an older example I used in an Android app on m5 - probably still works the same, nothing Android specific really in it, but I haven't tried it in 0.9 or 1.0 lately: private void callSocket(final String socketData) { String address = "192.168.0.12"; int port = 8889; Socket socket = null; BufferedWriter writer = null; BufferedReader reader = null; try { socket = new Socket(address, port); writer = new BufferedWriter(new OutputStreamWriter(socket .getOutputStream())); reader = new BufferedReader(new InputStreamReader(socket .getInputStream())); // send input terminated with \n String input = socketData; writer.write(input + "\n", 0, input.length() + 1); writer.flush(); // read back output String output = reader.readLine(); Log.d(Constants.LOGTAG, " " + CLASSTAG + " output - " + output); socketOutput.setText(output); // send EXIT and close writer.write("EXIT\n", 0, 5); writer.flush(); } catch (IOException e) { Log.e(Constants.LOGTAG, " " + CLASSTAG + " IOException calling socket", e); } finally { try { writer.close(); } catch (IOException e) { // swallow } try { reader.close(); } catch (IOException e) { // swallow } try { socket.close(); } catch (IOException e) { // swallow } } } On Sep 30, 12:16 pm, Wesley <[EMAIL PROTECTED]> wrote: > Hi, > > thanks for d reply. > > I have one more questions... > Did anyone know how to make socket connection using androird???? > > wesley. > > On 9/30/08, Charlie Collins <[EMAIL PROTECTED]> wrote: > > > > > > > I replied with some info on this over at Anddev where it was also > > asked - before I noticed this. > > >http://www.anddev.org/viewtopic.php?p=10646#10646 > > > HTH > > > On Sep 30, 4:23 am, Wesley Sagittarius <[EMAIL PROTECTED]> wrote: > >> hi all, > > >> I not quite familiar with android... hoping I can get some answer > >> here... thanks... > >> I have two questions here... > > >> 1st Question > >> --------------- > >> How can I use android to call a url and get the inputStream to get the > >> content of the pages??? > > >> Code in J2me:- > >> ------------------- > >> connection = (HttpConnection) Connector.open(Info.DeviceInfo.URL + "? > >> cmd=gses&userid=" + userSession); > >> connection.setRequestMethod(HttpConnection.GET); > > >> if (connection.getHeaderField("Set-Cookie") != null) { > >> cookie = connection.getHeaderField("Set-Cookie"); > >> } > > >> DataInputStream dis = connection.openDataInputStream(); > > >> int ch; > >> String str = ""; > > >> while ((ch = dis.read()) != -1) { > >> str += (char) ch; > > >> } > > >> 2nd Question > >> ---------------- > >> How can I get Stream Connection from a server using Android?? > > >> Coding in J2me > >> ------------------ > >> connection=(StreamConnection)Connector.open(DeviceInfo.URL_CONNECTION); > > >> inpStream = connection.openInputStream(); > >> outStream = connection.openOutputStream(); > > >> anyone have any example can show me??? > > >> wesley. > > -- > Sent from Gmail for mobile | mobile.google.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---