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. Certain apps not being shown in Android Market?

Just a thought :

What are the permissions listed under the require segment of your app
in your manifest file and what screen resolution do you support in
your apps ?

One of my apps doesn't show in the market for lower screen resolution
devices.
The require part of the manifest file might also filter out apps for
specific devices. Say if you specify that your app requires flash
capability for the camera, then all devices without flashes won't see
the app in the market.

Keep us updated.

Yahel





> 

2. Nubie di Pasar Malam

Teman2,

Pendaftaran saya di pasar malam sudah diapprove, dan sudah bisa login ke
web.
Dasar nubie, dah masuk pasar eh saya ngga tau musti ngapain. Jadi cuma
melongo2 aja ngeliatin etalasenya.
Mohon wejangan dng gimana caranya 'belanja' dan menginstall merchandise yg
bagus2 itu ke encus yang masih unrooted.

Thank you bangets,
IM

-- 
Win4Work | Mac4Fun | BB4Chat | Droid4Else
y!:papatuwa | g!/t/fb:papatua

-- 
"Indonesian Android Community [id-android]" 

3. Cara update Recovery RO

4. GridView - setting selection to last item also loads first item

5. regrading invisible( hide ) running service

6. HTC Evo selling like hot cakes

7. Strip html from String