Package org.apache.http.impl
Class SocketHttpClientConnection
java.lang.Object
org.apache.http.impl.AbstractHttpClientConnection
org.apache.http.impl.SocketHttpClientConnection
- All Implemented Interfaces:
HttpClientConnection,HttpConnection,HttpInetConnection
- Direct Known Subclasses:
DefaultClientConnection,DefaultHttpClientConnection
public class SocketHttpClientConnection extends AbstractHttpClientConnection implements HttpInetConnection
Implementation of a client-side HTTP connection that can be bound to a
network Socket in order to receive and transmit data.
- Since:
- 4.0
- Version:
- $Revision: 561083 $
- Author:
- Oleg Kalnichevski
-
Constructor Summary
Constructors Constructor Description SocketHttpClientConnection() -
Method Summary
Modifier and Type Method Description protected voidassertNotOpen()protected voidassertOpen()protected voidbind(Socket socket, HttpParams params)voidclose()Closes this connection gracefully.protected SessionInputBuffercreateSessionInputBuffer(Socket socket, int buffersize, HttpParams params)protected SessionOutputBuffercreateSessionOutputBuffer(Socket socket, int buffersize, HttpParams params)InetAddressgetLocalAddress()intgetLocalPort()InetAddressgetRemoteAddress()intgetRemotePort()protected SocketgetSocket()intgetSocketTimeout()Returns the socket timeout value.booleanisOpen()Checks if this connection is open.voidsetSocketTimeout(int timeout)Sets the socket timeout value.voidshutdown()Force-closes this connection.Methods inherited from class org.apache.http.impl.AbstractHttpClientConnection
createEntityDeserializer, createEntitySerializer, createHttpResponseFactory, createRequestWriter, createResponseParser, doFlush, flush, getMetrics, init, isResponseAvailable, isStale, receiveResponseEntity, receiveResponseHeader, sendRequestEntity, sendRequestHeader
-
Constructor Details
-
SocketHttpClientConnection
public SocketHttpClientConnection()
-
-
Method Details
-
assertNotOpen
protected void assertNotOpen() -
assertOpen
protected void assertOpen()- Specified by:
assertOpenin classAbstractHttpClientConnection
-
createSessionInputBuffer
protected SessionInputBuffer createSessionInputBuffer(Socket socket, int buffersize, HttpParams params) throws IOException- Throws:
IOException
-
createSessionOutputBuffer
protected SessionOutputBuffer createSessionOutputBuffer(Socket socket, int buffersize, HttpParams params) throws IOException- Throws:
IOException
-
bind
- Throws:
IOException
-
isOpen
public boolean isOpen()Description copied from interface:HttpConnectionChecks if this connection is open.- Specified by:
isOpenin interfaceHttpConnection- Returns:
- true if it is open, false if it is closed.
-
getSocket
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceHttpInetConnection
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfaceHttpInetConnection
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceHttpInetConnection
-
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin interfaceHttpInetConnection
-
setSocketTimeout
public void setSocketTimeout(int timeout)Description copied from interface:HttpConnectionSets the socket timeout value.- Specified by:
setSocketTimeoutin interfaceHttpConnection- Parameters:
timeout- timeout value in milliseconds
-
getSocketTimeout
public int getSocketTimeout()Description copied from interface:HttpConnectionReturns the socket timeout value.- Specified by:
getSocketTimeoutin interfaceHttpConnection- Returns:
- positive value in milliseconds if a timeout is set,
0if timeout is disabled or-1if timeout is undefined.
-
shutdown
Description copied from interface:HttpConnectionForce-closes this connection. This is the only method of a connection which may be called from a different thread to terminate the connection. This method will not attempt to flush the transmitter's internal buffer prior to closing the underlying socket.- Specified by:
shutdownin interfaceHttpConnection- Throws:
IOException
-
close
Description copied from interface:HttpConnectionCloses this connection gracefully. This method will attempt to flush the transmitter's internal buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Useshutdowninstead.- Specified by:
closein interfaceHttpConnection- Throws:
IOException
-