/** * Shutdown the server * * @param immediate boolean */ public void shutdownServer(boolean immediate) { // Stop the RPC handlers if (m_udpHandler != null) { m_udpHandler.closeSessionHandler(this); m_udpHandler = null; } if (m_tcpHandler != null) { m_tcpHandler.closeSessionHandler(this); m_tcpHandler = null; } // Fire a shutdown notification event fireServerEvent(ServerListener.ServerShutdown); }
/** Start the portmapper server */ public void startServer() { try { // Create the UDP RPC handler to accept incoming requests m_udpHandler = new UdpRpcDatagramHandler("PortMap", "Port", this, this, null, getPort(), MaxRequestSize); m_udpHandler.initializeSessionHandler(this); // Start the UDP request listener is a seperate thread Thread udpThread = new Thread(m_udpHandler); udpThread.setName("PortMap_UDP"); udpThread.start(); // Create the TCP RPC handler to accept incoming requests m_tcpHandler = new TcpRpcSessionHandler("PortMap", "Port", this, this, null, getPort(), MaxRequestSize); m_tcpHandler.initializeSessionHandler(this); // Start the UDP request listener is a seperate thread Thread tcpThread = new Thread(m_tcpHandler); tcpThread.setName("PortMap_TCP"); tcpThread.start(); // Add port mapper entries for the portmapper service PortMapping portMap = new PortMapping(PortMapper.ProgramId, PortMapper.VersionId, Rpc.UDP, getPort()); addPortMapping(portMap); portMap = new PortMapping(PortMapper.ProgramId, PortMapper.VersionId, Rpc.TCP, getPort()); addPortMapping(portMap); } catch (Exception ex) { Debug.println(ex); } }