org.apache.http.impl
Class DefaultHttpClientConnection

java.lang.Object
  extended by org.apache.http.impl.AbstractHttpClientConnection
      extended by org.apache.http.impl.SocketHttpClientConnection
          extended by org.apache.http.impl.DefaultHttpClientConnection
All Implemented Interfaces:
HttpClientConnection, HttpConnection, HttpInetConnection

public class DefaultHttpClientConnection
extends SocketHttpClientConnection

Default implementation of a client-side HTTP connection.

Since:
4.0
Version:
$Revision: 744524 $

Constructor Summary
DefaultHttpClientConnection()
           
 
Method Summary
 void bind(Socket socket, HttpParams params)
          Binds this connection to the given Socket.
 String toString()
           
 
Methods inherited from class org.apache.http.impl.SocketHttpClientConnection
assertNotOpen, assertOpen, close, createSessionInputBuffer, createSessionOutputBuffer, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, isOpen, setSocketTimeout, shutdown
 
Methods inherited from class org.apache.http.impl.AbstractHttpClientConnection
createEntityDeserializer, createEntitySerializer, createHttpResponseFactory, createRequestWriter, createResponseParser, doFlush, flush, getMetrics, init, isEof, isResponseAvailable, isStale, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.http.HttpConnection
getMetrics, isStale
 

Constructor Detail

DefaultHttpClientConnection

public DefaultHttpClientConnection()
Method Detail

bind

public void bind(Socket socket,
                 HttpParams params)
          throws IOException
Binds this connection to the given Socket. This socket will be used by the connection to send and receive data.

This method will invoke SocketHttpClientConnection.createSessionInputBuffer(Socket, int, HttpParams) and SocketHttpClientConnection.createSessionOutputBuffer(Socket, int, HttpParams) methods to create session input / output buffers bound to this socket and then will invoke AbstractHttpClientConnection.init(SessionInputBuffer, SessionOutputBuffer, HttpParams) method to pass references to those buffers to the underlying HTTP message parser and formatter.

After this method's execution the connection status will be reported as open and the SocketHttpClientConnection.isOpen() will return true.

The following HTTP parameters affect configuration of this connection:

The CoreConnectionPNames.SOCKET_BUFFER_SIZE parameter determines the size of the internal socket buffer. If not defined or set to -1 the default value will be chosen automatically.

CoreConnectionPNames.TCP_NODELAY parameter determines whether Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the cost of an increase in bandwidth consumption.

CoreConnectionPNames.SO_TIMEOUT parameter defines the socket timeout in milliseconds, which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.

CoreConnectionPNames.SO_LINGER parameter defines linger time in seconds. The maximum timeout value is platform specific. Value 0 implies that the option is disabled. Value -1 implies that the JRE default is to be used. The setting only affects socket close.

Overrides:
bind in class SocketHttpClientConnection
Parameters:
socket - the socket.
params - HTTP parameters.
Throws:
IOException - in case of an I/O error.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.