示例#1
0
  /**
   * Start server
   *
   * @return if server starts successfully, return true.
   */
  @SuppressWarnings("unused")
  public boolean startServer() {
    try {
      serverSocket = new ServerSocket(serverPort);
      Log.i(TAG, "Create Server Socket at port " + serverPort);

      listeningThread.setServerSocket(serverSocket);
      listeningThread.start();

      return true;
    } catch (IOException e) {
      Log.i(TAG, "Creating server failed");
      e.printStackTrace();
      return false;
    }
  }
示例#2
0
 /**
  * add public path
  *
  * @param path root path of public files
  */
 @SuppressWarnings("unused")
 public void addPublic(String path) {
   File f = new File(path);
   if (!f.isDirectory()) {
     Log.e(TAG, path + " is not directory!!");
   } else {
     publics.add(path);
   }
 }
示例#3
0
 /** Stop server */
 @SuppressWarnings("unused")
 public void stopServer() {
   try {
     Log.i(TAG, "Stop Server");
     if (serverSocket.isBound()) {
       serverSocket.close();
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
示例#4
0
 /**
  * Set server port
  *
  * @param port port
  */
 @SuppressWarnings("unused")
 public void setPort(int port) {
   Log.i(TAG, "Set Port : " + port);
   this.serverPort = port;
 }