bob wrote:
> You can definitely create a TCP server on Android.
>
> The code would look like this:
>
> ServerSocket serverSocket = null;
>
Not really necessary to initialize to 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();
>
Well, obviously we're leaving out error handling for readability.
And curly braces for a less obvious reason.
--
Lew
--
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