/** * Listen for incoming and outgoing requests. If the {@code serverEnabled} * member is {@code false} the server for incoming requests is not * started. This starts the internal server thread that processes messages. * * @throws java.net.SocketException * when the transport is already listening for incoming/outgoing messages. * @throws java.io.IOException * if the listen port could not be bound to the server thread. */ public synchronized void listen() throws IOException { if (server != null) { throw new SocketException("Port already listening"); } try { serverThread = new ServerThread(); if (logger.isInfoEnabled()) { logger.info("TCP address " + tcpAddress + " bound successfully"); } } catch (NoSuchAlgorithmException e) { throw new IOException("SSL not available: " + e.getMessage(), e); } server = SNMP4JSettings.getThreadFactory().createWorkerThread( "TLSTM_" + getListenAddress(), serverThread, true); if (connectionTimeout > 0) { // run as daemon socketCleaner = SNMP4JSettings.getTimerFactory().createTimer(); } server.run(); }
/** * Listen for incoming and outgoing requests. If the {@code serverEnabled} * member is {@code false} the server for incoming requests is not * started. This starts the internal server thread that processes messages. * @throws java.net.SocketException * when the transport is already listening for incoming/outgoing messages. * @throws java.io.IOException * if the listen port could not be bound to the server thread. */ public synchronized void listen() throws IOException { if (server != null) { throw new SocketException("Port already listening"); } try { serverThread = new ServerThread(); if (logger.isInfoEnabled()) { logger.info("TCP address "+getListenAddress()+" bound successfully"); } } catch (NoSuchAlgorithmException e) { throw new IOException("SSL not available: "+e.getMessage(), e); } server = SNMP4JSettings.getThreadFactory().createWorkerThread( "TLSTM_"+getAddress(), serverThread, true); if (connectionTimeout > 0) { // run as daemon socketCleaner = SNMP4JSettings.getTimerFactory().createTimer(); } server.run(); }