org.apache.http.impl
Class DefaultHttpServerConnection

java.lang.Object
  extended by org.apache.http.impl.AbstractHttpServerConnection
      extended by org.apache.http.impl.SocketHttpServerConnection
          extended by org.apache.http.impl.DefaultHttpServerConnection
All Implemented Interfaces:
HttpConnection, HttpInetConnection, HttpServerConnection

public class DefaultHttpServerConnection
extends SocketHttpServerConnection

Default implementation of a server-side HTTP connection.

Since:
4.0
Version:
$Revision: 744524 $

Constructor Summary
DefaultHttpServerConnection()
           
 
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.SocketHttpServerConnection
assertNotOpen, assertOpen, close, createHttpDataReceiver, createHttpDataTransmitter, createSessionInputBuffer, createSessionOutputBuffer, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, isOpen, setSocketTimeout, shutdown
 
Methods inherited from class org.apache.http.impl.AbstractHttpServerConnection
createEntityDeserializer, createEntitySerializer, createHttpRequestFactory, createRequestParser, createResponseWriter, doFlush, flush, getMetrics, init, isEof, isStale, receiveRequestEntity, receiveRequestHeader, sendResponseEntity, sendResponseHeader
 
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

DefaultHttpServerConnection

public DefaultHttpServerConnection()
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 SocketHttpServerConnection.createSessionInputBuffer(Socket, int, HttpParams) and SocketHttpServerConnection.createSessionOutputBuffer(Socket, int, HttpParams) methods to create session input / output buffers bound to this socket and then will invoke AbstractHttpServerConnection.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 SocketHttpServerConnection.isOpen() will return true.

The following HTTP parameters affect configuration 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 SocketHttpServerConnection
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.