Question about ServerSocket

by riverwide » Sat, 15 Nov 2008 00:14:25 GMT


Sponsored Links
 Hi,

I want to new a ServerSocket instance.(java.net.ServerSocket) But I
can't.
A java.net.BindException was throws.(java.net.BindException:
Permission do not allow action on socket)

Is it possible to use the ServerSocket class in Android ?
I've found the ServerSocket page in API document.(http://
code.google.com/android/reference/java/net/ServerSocket.html)

Thank you for any pointers.

riverwide

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



Question about ServerSocket

by Alvin Yates » Sat, 15 Nov 2008 02:37:42 GMT


 If it's on the page, more than likely.  However, if you haven't set
your manifest file to add the NETWORK permission, that would do it
easily.



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


Sponsored Links


Question about ServerSocket

by linker lv » Sat, 15 Nov 2008 07:19:46 GMT


 just need give the permission.
android.permission.INTERNET

2008/11/14 riverwide <[EMAIL PROTECTED]>


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



Question about ServerSocket

by 宸濋倞娉拌獙 » Mon, 17 Nov 2008 17:04:13 GMT


 Hi,

I had tried to give the permission "android.permission.INTERNET",
using telnet and execute a command "redir add tcp:400:400".
But, same exception "A java.net.BindException" was thrown.

It questions again.
Is it possible to use the ServerSocket class in Android ?

The following are my codes.
//! STR my code
try
{
    ServerSocket srvrSock = new ServerSocket(400);
}
catch(IOException e)
{
    e.printStackTrace();
}
catch(Exception e)
{
    e.printStackTrace();
}
//! END my code

Thank you for any pointers.

riverwide

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



Question about ServerSocket

by linker lv » Tue, 18 Nov 2008 09:45:01 GMT


 public static final int SERVERPORT = 4444;
public void server()
    {
     DataOutputStream os=null;
        DataInputStream is = null;
        ServerSocket socket = null;
        Socket ClientSocket = null;
        String out = null;
        try
        {
         socket = new ServerSocket(SERVERPORT);//10.0.2.2

         if(socket == null)
         {
          Log.d("TagServer()", "socket null");
         }
         else
         {
          Log.d("TagServer()", "Waiting...");
          ClientSocket = socket.accept();
                os = new DataOutputStream(ClientSocket.getOutputStream());
                is = new DataInputStream(ClientSocket.getInputStream());
                /* By magic we know, how much data will be waiting for us*/
                byte[] buf = new byte[100];
                int readLen = 0;
                while((readLen = is.read(buf, 0, 100)) != -1)
                {
                 out = new String(buf, 0, readLen-1);
                 Log.d("TCP", out);
                 os.writeBytes("end");
                }
                os.close();
                is.close();
                socket.close();
                ClientSocket.close();
                Log.d("TagServer()", "Finished");
         }
        }
        catch(Exception e)
        {
         System.out.println(e);
         Log.d("TagServer()", e.toString());
        }
    }

i think you can understand it.

2008/11/17  <[EMAIL PROTECTED]>


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



Question about ServerSocket

by Brian Manning » Tue, 18 Nov 2008 23:12:11 GMT


 


Does Android still adhere to the *NIX convention of only allowing the
root user to bind to ports 1-1024?  I'm not seeing anything in the
socket classes that is saying different, so I'm assuming this is the
case.  You might want to try binding your socket to a port above 1024
to see if that changes things.

Thanks,

Brian

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



Question about ServerSocket

by riverwide » Wed, 19 Nov 2008 12:48:46 GMT


 Hi,

Certainly, when the port of waiting for the server was assumed to be
"well known ports(0-1024)", the exception was thrown.

When I use a port above 1024, I was able to new a ServerSocket instance.

It doesn't operate according to the expectation though I am trying use port
4000, now.

On the another PC, execute a command "telnet emulator PC's machine 4000".
But, it is not possible to connect to the emulator PC.

thanks

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



Question about ServerSocket

by linker lv » Wed, 19 Nov 2008 13:25:52 GMT


 you must use "telnet 10.0.2.2" if you want to telnet to emulator.
10.0.2.2: emulator's IP.

2008/11/19 riverwide <[EMAIL PROTECTED]>


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



Other Threads

1. Parsing Dates in other Locales

I need to parse a date using a flexible date format (like "MM/dd/yyyy"
or "dd-MMM"), and so far I've always used SimpleDateFormat for that
(since unfortunately, android.text.format.Time.parse doesn't support
date format strings). This works fine in an US environment, but as
soon as I switch to any other locale, MMM translates into the number
of the month (i.e. it's "6" instead of "Jun"). This seems like a
problem that's new to Cupcake, although I'm not sure.

Is there any way to parse date strings in another locale other than
writing my own parser? android.text.format.DateFormat.format is great
for converting from date to string, but I can't find anything going
the other way around.

-Mike


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

2. Help with Services

Hi all,
              i'm starting an activity that inturn calls a service.... i
wanna get notified when the service competes...
can anyone temme how i can do this???

-- 
Regards,
Sujay
Bette Davis <http://www.brainyquote.com/quotes/authors/b/bette_davis.html>
- "Brought up to respect the conventions, love had to end in marriage.
I'm
afraid it did."

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

3. Screen Brightness

4. emulator rotation on 1.5 with no keyboard on the device

5. xmlbeans support in 1.5

6. Toast without light up

7. SDCard becoming un-writeable