Java:

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;
                     boolean listening = true;


                     while(listening == true)
                     //while((out != "end") || (readLen = is.read(buf,
0, 100)) != -1)
                     //while (out != "end")
                     {

                      if ((readLen = is.read(buf, 0, 100)) != -1){
                      out = new String(buf, 0, readLen-1);
                      Log.d("TCP", out);
                      os.writeBytes("gotit");

                      String test = out.toString();

                      if (test != "end")
                         {
                              listening = true;
                          }else{
                              listening = false;
                          }
                      }

                     }
                     os.close();
                     is.close();
                     socket.close();
                     ClientSocket.close();
                     Log.d("TagServer()", "Finished");
              }
             }
             catch(Exception e)
             {
              System.out.println(e);
              Log.d("TagServer()", e.toString());
             }
         }


Ok I am trying to be able to stop listening for packets and I am
trying to do that with the test variable.
no matter what it seems that test never = ends.

Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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