Yes, but doing that (as I said) lends itself to an everlasting
service: you certainly can't run that code on the UI thread (it will
simply barf with an exception), and so the sensible place to put it is
in a service..  There might be times when this is acceptable, but you
should think about it carefully before doing so to make sure there
isn't a better solution.

Kris

On Wed, Jan 9, 2013 at 6:06 PM, bob <[email protected]> wrote:
> You can definitely create a TCP server on Android.
>
> The code would look like this:
>
> ServerSocket serverSocket = null;
> boolean listening = true;
>
> try {
> serverSocket = new ServerSocket(1101);
> } catch (IOException e) {
> System.err.println("Could not listen on port: 1101.");
> System.exit(-1);
> }
>
> while (listening)
> new Server_Thread(serverSocket.accept()).start();
>
> serverSocket.close();
>
>
>
>
> On Wednesday, January 9, 2013 3:41:22 AM UTC-6, tom wrote:
>>
>> Hi,
>>
>> why couldn't create webservice  using android?
>> if that any reason. if you know that reason...please share with me..
>>
>> Thanks,
>> Tom
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" 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-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to