1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.server; 20 21 import java.io.Closeable; 22 import java.io.IOException; 23 24 /** 25 * <p>A {@link Connector} for TCP/IP network connectors</p> 26 */ 27 public interface NetworkConnector extends Connector, Closeable 28 { 29 /** 30 * <p>Performs the activities needed to open the network communication 31 * (for example, to start accepting incoming network connections).</p> 32 * 33 * @throws IOException if this connector cannot be opened 34 * @see #close() 35 */ 36 void open() throws IOException; 37 38 /** 39 * <p>Performs the activities needed to close the network communication 40 * (for example, to stop accepting network connections).</p> 41 * Once a connector has been closed, it cannot be opened again without first 42 * calling {@link #stop()} and it will not be active again until a subsequent call to {@link #start()} 43 */ 44 @Override 45 void close(); 46 47 /* ------------------------------------------------------------ */ 48 /** 49 * A Connector may be opened and not started (to reserve a port) 50 * or closed and running (to allow graceful shutdown of existing connections) 51 * @return True if the connector is Open. 52 */ 53 boolean isOpen(); 54 55 /** 56 * @return The hostname representing the interface to which 57 * this connector will bind, or null for all interfaces. 58 */ 59 String getHost(); 60 61 /** 62 * @return The configured port for the connector or 0 if any available 63 * port may be used. 64 */ 65 int getPort(); 66 67 /** 68 * @return The actual port the connector is listening on, or 69 * -1 if it has not been opened, or -2 if it has been closed. 70 */ 71 int getLocalPort(); 72 }