/** * Constructor. Establishes a TCP socket connection with the DHCP client daemon on port 5818. * * @throws IOException if unable to establish the connection with the DHCP client daemon. */ private Poller(long timeout) throws IOException { DhcpdConfigFactory dcf = DhcpdConfigFactory.getInstance(); try { LOG.debug( "Poller.ctor: opening socket connection with DHCP client daemon on port {}", dcf.getPort()); m_connection = new Socket(InetAddressUtils.addr("127.0.0.1"), dcf.getPort()); LOG.debug("Poller.ctor: setting socket timeout to {}", timeout); m_connection.setSoTimeout((int) timeout); // Establish input/output object streams m_ins = new ObjectInputStream(m_connection.getInputStream()); m_outs = new ObjectOutputStream(m_connection.getOutputStream()); m_outs.reset(); m_outs.flush(); } catch (IOException ex) { LOG.error("IO Exception during socket connection establishment with DHCP client daemon.", ex); if (m_connection != null) { try { m_ins.close(); m_outs.close(); m_connection.close(); } catch (Throwable t) { } } throw ex; } catch (Throwable t) { LOG.error( "Unexpected exception during socket connection establishment with DHCP client daemon.", t); if (m_connection != null) { try { m_ins.close(); m_outs.close(); m_connection.close(); } catch (Throwable tx) { } } throw new UndeclaredThrowableException(t); } }