コード例 #1
0
  /** Destroy the server */
  public void destroy() {
    closeAllSockets();

    if (serverSocket != null) {
      try {
        serverSocket.close();
      } catch (IOException e) {
        Util.printStackTrace(e);
      }
      serverSocket = null;
    }
  }
コード例 #2
0
 /**
  * Create a new ContextServer using the ThreadPool.
  *
  * @param threadPool Obtain runnables from this pool. If null, new threads will be created.
  */
 public SocketContextServer(AppThreadPool threadPool, boolean promiscuous, String contextName) {
   this.threadPool = threadPool;
   this.contextName = contextName;
   try {
     serverSocket = JavaBridge.bind(promiscuous ? "INET:0" : "INET_LOCAL:0");
     SecurityManager sec = System.getSecurityManager();
     if (sec != null) sec.checkAccept("127.0.0.1", Integer.parseInt(serverSocket.getSocketName()));
     Thread t =
         new Util.Thread(
             this, "JavaBridgeSocketContextServer(" + serverSocket.getSocketName() + ")");
     t.start();
   } catch (Throwable t) {
     Util.warn("Local communication channel not available.");
     Util.printStackTrace(t);
     if (serverSocket != null)
       try {
         serverSocket.close();
       } catch (IOException e) {
       }
     serverSocket = null;
   }
 }
コード例 #3
0
 /**
  * Returns the server port.
  *
  * @return The server port.
  */
 public String getChannelName() {
   return serverSocket.getSocketName();
 }