KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > net > SocketFactory


1 /*
2  * @(#)SocketFactory.java 1.9 04/02/16
3  *
4  * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7   
8 /*
9  * NOTE:
10  * Because of various external restrictions (i.e. US export
11  * regulations, etc.), the actual source code can not be provided
12  * at this time. This file represents the skeleton of the source
13  * file, so that javadocs of the API can be created.
14  */

15
16 package javax.net;
17
18 import java.net.*;
19
20 import java.io.IOException;
21
22 /**
23  * This class creates sockets. It may be subclassed by other factories,
24  * which create particular subclasses of sockets and thus provide a general
25  * framework for the addition of public socket-level functionality.
26  *
27  * <P> Socket factories are a simple way to capture a variety of policies
28  * related to the sockets being constructed, producing such sockets in
29  * a way which does not require special configuration of the code which
30  * asks for the sockets: <UL>
31  *
32  * <LI> Due to polymorphism of both factories and sockets, different
33  * kinds of sockets can be used by the same application code just
34  * by passing it different kinds of factories.
35  *
36  * <LI> Factories can themselves be customized with parameters used
37  * in socket construction. So for example, factories could be
38  * customized to return sockets with different networking timeouts
39  * or security parameters already configured.
40  *
41  * <LI> The sockets returned to the application can be subclasses
42  * of java.net.Socket, so that they can directly expose new APIs
43  * for features such as compression, security, record marking,
44  * statistics collection, or firewall tunneling.
45  *
46  * </UL>
47  *
48  * <P> Factory classes are specified by environment-specific configuration
49  * mechanisms. For example, the <em>getDefault</em> method could return
50  * a factory that was appropriate for a particular user or applet, and a
51  * framework could use a factory customized to its own purposes.
52  *
53  * @since 1.4
54  * @see ServerSocketFactory
55  *
56  * @version 1.17
57  * @author David Brownell
58  */

59 public abstract class SocketFactory
60 {
61
62     /**
63      * Creates a <code>SocketFactory</code>.
64      */

65     protected SocketFactory() { }
66
67     /**
68      * Returns a copy of the environment's default socket factory.
69      *
70      * @return the default <code>SocketFactory</code>
71      */

72     public static SocketFactory getDefault() {
73         return null;
74     }
75
76     /**
77      * Creates an unconnected socket.
78      *
79      * @return the unconnected socket
80      * @throws IOException if the socket cannot be created
81      * @see java.net.Socket#connect(java.net.SocketAddress)
82      * @see java.net.Socket#connect(java.net.SocketAddress, int)
83      * @see java.net.Socket#Socket()
84      */

85     public Socket createSocket() throws IOException {
86         return null;
87     }
88
89     /**
90      * Creates a socket and connects it to the specified remote host
91      * at the specified remote port. This socket is configured using
92      * the socket options established for this factory.
93      *
94      * @param host the server host
95      * @param port the server port
96      * @return the <code>Socket</code>
97      * @throws IOException if an I/O error occurs when creating the socket
98      * @throws UnknownHostException if the host is not known
99      * @see java.net.Socket#Socket(String, int)
100      */

101     public abstract Socket createSocket(String host, int port)
102         throws IOException, UnknownHostException;
103
104     /**
105      * Creates a socket and connects it to the specified remote host
106      * on the specified remote port.
107      * The socket will also be bound to the local address and port supplied.
108      * This socket is configured using
109      * the socket options established for this factory.
110      *
111      * @param host the server host
112      * @param port the server port
113      * @param localHost the local address the socket is bound to
114      * @param localPort the local port the socket is bound to
115      * @return the <code>Socket</code>
116      * @throws IOException if an I/O error occurs when creating the socket
117      * @throws UnknownHostException if the host is not known
118      * @see java.net.Socket#Socket(String, int, java.net.InetAddress, int)
119      */

120     public abstract Socket createSocket(String host, int port, InetAddress
121         localHost, int localPort) throws IOException, UnknownHostException;
122
123     /**
124      * Creates a socket and connects it to the specified port number
125      * at the specified address. This socket is configured using
126      * the socket options established for this factory.
127      *
128      * @param host the server host
129      * @param port the server port
130      * @return the <code>Socket</code>
131      * @throws IOException if an I/O error occurs when creating the socket
132      * @see java.net.Socket#Socket(java.net.InetAddress, int)
133      */

134     public abstract Socket createSocket(InetAddress host, int port)
135         throws IOException;
136
137     /**
138      * Creates a socket and connect it to the specified remote address
139      * on the specified remote port. The socket will also be bound
140      * to the local address and port suplied. The socket is configured using
141      * the socket options established for this factory.
142      *
143      * @param address the server network address
144      * @param port the server port
145      * @param localAddress the client network address
146      * @param localPort the client port
147      * @return the <code>Socket</code>
148      * @throws IOException if an I/O error occurs when creating the socket
149      * @see java.net.Socket#Socket(java.net.InetAddress, int,
150      * java.net.InetAddress, int)
151      */

152     public abstract Socket createSocket(InetAddress address, int port,
153         InetAddress localAddress, int localPort) throws IOException;
154 }
155
Popular Tags