Android APIs
public final class

PlainSocketFactory

extends Object
implements SocketFactory
java.lang.Object
   ↳ org.apache.http.conn.scheme.PlainSocketFactory

This class is deprecated.
Please use openConnection() instead. Please visit this webpage for further details.

Class Overview

The default class for creating sockets.

Summary

Public Constructors
PlainSocketFactory(HostNameResolver nameResolver)
PlainSocketFactory()
Public Methods
Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params)
Connects a socket to the given host.
Socket createSocket()
Creates a new, unconnected socket.
boolean equals(Object obj)
Compares this factory with an object.
static PlainSocketFactory getSocketFactory()
Gets the singleton instance of this class.
int hashCode()
Obtains a hash code for this object.
final boolean isSecure(Socket sock)
Checks whether a socket connection is secure.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.conn.scheme.SocketFactory

Public Constructors

public PlainSocketFactory (HostNameResolver nameResolver)

Added in API level 1

public PlainSocketFactory ()

Added in API level 1

Public Methods

public Socket connectSocket (Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params)

Added in API level 1

Connects a socket to the given host.

Parameters
sock the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.
host the host to connect to
port the port to connect to on the host
localAddress the local address to bind the socket to, or null for any
localPort the port on the local machine, 0 or a negative number for any
params additional parameters for connecting
Returns
  • the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.
Throws
IOException

public Socket createSocket ()

Added in API level 1

Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket.

Returns
  • a new socket

public boolean equals (Object obj)

Added in API level 1

Compares this factory with an object. There is only one instance of this class.

Parameters
obj the object to compare with
Returns
  • iff the argument is this object

public static PlainSocketFactory getSocketFactory ()

Added in API level 1

Gets the singleton instance of this class.

Returns
  • the one and only plain socket factory

public int hashCode ()

Added in API level 1

Obtains a hash code for this object. All instances of this class have the same hash code. There is only one instance of this class.

Returns
  • this object's hash code.

public final boolean isSecure (Socket sock)

Added in API level 1

Checks whether a socket connection is secure. This factory creates plain socket connections which are not considered secure.

Parameters
sock the connected socket
Returns
  • false
Throws
IllegalArgumentException if the argument is invalid