unitServer.java :  » UnTagged » mastercontroller » udpUnitAdapt » Android Open Source

Android Open Source » UnTagged » mastercontroller 
mastercontroller » udpUnitAdapt » unitServer.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package udpUnitAdapt;

import java.io.IOException;
import java.net.DatagramSocket;

/**
 *
 * @author axelsben
 */
public class unitServer {
    udpServer us = new udpServer();
    int useSocket = 0;

    unitServer(String server, int port)
    {
        us.setAddress(server);
        us.setSocket(port);
        us.setLogging(false);
        useSocket = port;
        
        srvThread st;
    try {
      st = new srvThread();
          st.start();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    }
    public class srvThread extends Thread
    {
        protected DatagramSocket socket = null;

        public srvThread() throws IOException
        {
            this("unitSrvThread");
        }

        public srvThread(String name) throws IOException
        {
            super(name);
            socket = new DatagramSocket(useSocket);
        }


        @Override
        public void run() {
          while(true){
              byte[] byteArray = us.receive(socket);
              adaptor.unit2app(byteArray);
          }
        }
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.