to top
Android APIs
public final class

PlainSocketFactory

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

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)

Since: API Level 1

public PlainSocketFactory ()

Since: API Level 1

Public Methods

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

Since: 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 ()

Since: 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)

Since: 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 ()

Since: API Level 1

Gets the singleton instance of this class.

Returns
  • the one and only plain socket factory

public int hashCode ()

Since: 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)

Since: 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