FileDocCategorySizeDatePackage
SocketFactory.javaAPI DocAndroid 1.5 API6254Wed May 06 22:41:06 BST 2009javax.net

SocketFactory

public abstract class SocketFactory extends Object
This abstract class defines methods to create sockets. It can be subclassed to create specific socket types with additional socket-level functionality.
since
Android 1.0

Fields Summary
static SocketFactory
defaultFactory
Constructors Summary
protected SocketFactory()
Creates a new {@code SocketFactory} instance.

since
Android 1.0

    
Methods Summary
public java.net.SocketcreateSocket()
Creates a new socket which is not connected to any remote host. This method has to be overridden by a subclass otherwise a {@code SocketException} is thrown.

return
the created unconnected socket.
throws
IOException if an error occurs while creating a new socket.
since
Android 1.0

        // follow RI's behavior 
        throw new SocketException("Unconnected sockets not implemented");
    
public abstract java.net.SocketcreateSocket(java.lang.String host, int port)
Creates a new socket which is connected to the remote host specified by the parameters {@code host} and {@code port}. The socket is bound to any available local address and port.

param
host the remote host address the socket has to be connected to.
param
port the port number of the remote host at which the socket is connected.
return
the created connected socket.
throws
IOException if an error occurs while creating a new socket.
throws
UnknownHostException if the specified host is unknown or the IP address could not be resolved.
since
Android 1.0

public abstract java.net.SocketcreateSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort)
Creates a new socket which is connected to the remote host specified by the parameters {@code host} and {@code port}. The socket is bound to the local network interface specified by the InetAddress {@code localHost} on port {@code localPort}.

param
host the remote host address the socket has to be connected to.
param
port the port number of the remote host at which the socket is connected.
param
localHost the local host address the socket is bound to.
param
localPort the port number of the local host at which the socket is bound.
return
the created connected socket.
throws
IOException if an error occurs while creating a new socket.
throws
UnknownHostException if the specified host is unknown or the IP address could not be resolved.
since
Android 1.0

public abstract java.net.SocketcreateSocket(java.net.InetAddress host, int port)
Creates a new socket which is connected to the remote host specified by the InetAddress {@code host}. The socket is bound to any available local address and port.

param
host the host address the socket has to be connected to.
param
port the port number of the remote host at which the socket is connected.
return
the created connected socket.
throws
IOException if an error occurs while creating a new socket.
since
Android 1.0

public abstract java.net.SocketcreateSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort)
Creates a new socket which is connected to the remote host specified by the InetAddress {@code address}. The socket is bound to the local network interface specified by the InetAddress {@code localHost} on port {@code localPort}.

param
address the remote host address the socket has to be connected to.
param
port the port number of the remote host at which the socket is connected.
param
localAddress the local host address the socket is bound to.
param
localPort the port number of the local host at which the socket is bound.
return
the created connected socket.
throws
IOException if an error occurs while creating a new socket.
since
Android 1.0

public static synchronized javax.net.SocketFactorygetDefault()
Gets the default socket factory of the system which can be used to create new sockets without creating a subclass of this factory.

return
the system default socket factory.
since
Android 1.0

        if (defaultFactory == null) {
            defaultFactory = new DefaultSocketFactory();
        }
        return defaultFactory;