001: /*
002: * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java,v 1.10 2004/05/13 04:01:22 mbecke Exp $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030:
031: package org.apache.commons.httpclient.protocol;
032:
033: import java.io.IOException;
034: import java.net.InetAddress;
035: import java.net.Socket;
036: import java.net.UnknownHostException;
037:
038: import org.apache.commons.httpclient.ConnectTimeoutException;
039: import org.apache.commons.httpclient.params.HttpConnectionParams;
040:
041: /**
042: * A factory for creating Sockets.
043: *
044: * <p>Both {@link java.lang.Object#equals(java.lang.Object) Object.equals()} and
045: * {@link java.lang.Object#hashCode() Object.hashCode()} should be overridden appropriately.
046: * Protocol socket factories are used to uniquely identify <code>Protocol</code>s and
047: * <code>HostConfiguration</code>s, and <code>equals()</code> and <code>hashCode()</code> are
048: * required for the correct operation of some connection managers.</p>
049: *
050: * @see Protocol
051: *
052: * @author Michael Becke
053: * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
054: *
055: * @since 2.0
056: */
057: public interface ProtocolSocketFactory {
058:
059: /**
060: * Gets a new socket connection to the given host.
061: *
062: * @param host the host name/IP
063: * @param port the port on the host
064: * @param localAddress the local host name/IP to bind the socket to
065: * @param localPort the port on the local machine
066: *
067: * @return Socket a new socket
068: *
069: * @throws IOException if an I/O error occurs while creating the socket
070: * @throws UnknownHostException if the IP address of the host cannot be
071: * determined
072: */
073: Socket createSocket(String host, int port,
074: InetAddress localAddress, int localPort)
075: throws IOException, UnknownHostException;
076:
077: /**
078: * Gets a new socket connection to the given host.
079: *
080: * @param host the host name/IP
081: * @param port the port on the host
082: * @param localAddress the local host name/IP to bind the socket to
083: * @param localPort the port on the local machine
084: * @param params {@link HttpConnectionParams Http connection parameters}
085: *
086: * @return Socket a new socket
087: *
088: * @throws IOException if an I/O error occurs while creating the socket
089: * @throws UnknownHostException if the IP address of the host cannot be
090: * determined
091: * @throws ConnectTimeoutException if socket cannot be connected within the
092: * given time limit
093: *
094: * @since 3.0
095: */
096: Socket createSocket(String host, int port,
097: InetAddress localAddress, int localPort,
098: HttpConnectionParams params) throws IOException,
099: UnknownHostException, ConnectTimeoutException;
100:
101: /**
102: * Gets a new socket connection to the given host.
103: *
104: * @param host the host name/IP
105: * @param port the port on the host
106: *
107: * @return Socket a new socket
108: *
109: * @throws IOException if an I/O error occurs while creating the socket
110: * @throws UnknownHostException if the IP address of the host cannot be
111: * determined
112: */
113: Socket createSocket(String host, int port) throws IOException,
114: UnknownHostException;
115:
116: }
|