View Javadoc
1 package org.apache.commons.net; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Commons" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 import java.io.IOException; 58 import java.net.InetAddress; 59 import java.net.ServerSocket; 60 import java.net.Socket; 61 import java.net.UnknownHostException; 62 63 /**** 64 * The SocketFactory interface provides a means for the programmer to 65 * control the creation of sockets and provide his own Socket 66 * implementations for use by all classes derived from 67 * <a href="org.apache.commons.net.SocketClient.html"> SocketClient </a>. 68 * This allows you to provide your own Socket implementations and 69 * to perform security checks or browser capability requests before 70 * creating a Socket. 71 * <p> 72 * <p> 73 * @author Daniel F. Savarese 74 * @see DefaultSocketFactory 75 ***/ 76 77 public interface SocketFactory 78 { 79 80 /**** 81 * Creates a Socket connected to the given host and port. 82 * <p> 83 * @param host The hostname to connect to. 84 * @param port The port to connect to. 85 * @return A Socket connected to the given host and port. 86 * @exception UnknownHostException If the hostname cannot be resolved. 87 * @exception IOException If an I/O error occurs while creating the Socket. 88 ***/ 89 public Socket createSocket(String host, int port) 90 throws UnknownHostException, IOException; 91 92 93 /**** 94 * Creates a Socket connected to the given host and port. 95 * <p> 96 * @param address The address of the host to connect to. 97 * @param port The port to connect to. 98 * @return A Socket connected to the given host and port. 99 * @exception IOException If an I/O error occurs while creating the Socket. 100 ***/ 101 public Socket createSocket(InetAddress address, int port) 102 throws IOException; 103 104 105 /**** 106 * Creates a Socket connected to the given host and port and 107 * originating from the specified local address and port. 108 * <p> 109 * @param host The hostname to connect to. 110 * @param port The port to connect to. 111 * @param localAddr The local address to use. 112 * @param localPort The local port to use. 113 * @return A Socket connected to the given host and port. 114 * @exception UnknownHostException If the hostname cannot be resolved. 115 * @exception IOException If an I/O error occurs while creating the Socket. 116 ***/ 117 public Socket createSocket(String host, int port, InetAddress localAddr, 118 int localPort) 119 throws UnknownHostException, IOException; 120 121 /**** 122 * Creates a Socket connected to the given host and port and 123 * originating from the specified local address and port. 124 * <p> 125 * @param address The address of the host to connect to. 126 * @param port The port to connect to. 127 * @param localAddr The local address to use. 128 * @param localPort The local port to use. 129 * @return A Socket connected to the given host and port. 130 * @exception IOException If an I/O error occurs while creating the Socket. 131 ***/ 132 public Socket createSocket(InetAddress address, int port, 133 InetAddress localAddr, int localPort) 134 throws IOException; 135 136 /**** 137 * Creates a ServerSocket bound to a specified port. A port 138 * of 0 will create the ServerSocket on a system-determined free port. 139 * <p> 140 * @param port The port on which to listen, or 0 to use any free port. 141 * @return A ServerSocket that will listen on a specified port. 142 * @exception IOException If an I/O error occurs while creating 143 * the ServerSocket. 144 ***/ 145 public ServerSocket createServerSocket(int port) throws IOException; 146 147 /**** 148 * Creates a ServerSocket bound to a specified port with a given 149 * maximum queue length for incoming connections. A port of 0 will 150 * create the ServerSocket on a system-determined free port. 151 * <p> 152 * @param port The port on which to listen, or 0 to use any free port. 153 * @param backlog The maximum length of the queue for incoming connections. 154 * @return A ServerSocket that will listen on a specified port. 155 * @exception IOException If an I/O error occurs while creating 156 * the ServerSocket. 157 ***/ 158 public ServerSocket createServerSocket(int port, int backlog) 159 throws IOException; 160 161 /**** 162 * Creates a ServerSocket bound to a specified port on a given local 163 * address with a given maximum queue length for incoming connections. 164 * A port of 0 will 165 * create the ServerSocket on a system-determined free port. 166 * <p> 167 * @param port The port on which to listen, or 0 to use any free port. 168 * @param backlog The maximum length of the queue for incoming connections. 169 * @param bindAddr The local address to which the ServerSocket should bind. 170 * @return A ServerSocket that will listen on a specified port. 171 * @exception IOException If an I/O error occurs while creating 172 * the ServerSocket. 173 ***/ 174 public ServerSocket createServerSocket(int port, int backlog, 175 InetAddress bindAddr) 176 throws IOException; 177 }

This page was automatically generated by Maven