Package org.apache.http.impl
Class SocketHttpServerConnection
java.lang.Object
org.apache.http.impl.AbstractHttpServerConnection
org.apache.http.impl.SocketHttpServerConnection
- All Implemented Interfaces:
HttpConnection,HttpInetConnection,HttpServerConnection
- Direct Known Subclasses:
DefaultHttpServerConnection
public class SocketHttpServerConnection extends AbstractHttpServerConnection implements HttpInetConnection
Implementation of a server-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 SocketHttpServerConnection() -
Method Summary
Modifier and Type Method Description protected voidassertNotOpen()protected voidassertOpen()protected voidbind(Socket socket, HttpParams params)voidclose()Closes this connection gracefully.protected SessionInputBuffercreateHttpDataReceiver(Socket socket, int buffersize, HttpParams params)protected SessionOutputBuffercreateHttpDataTransmitter(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.AbstractHttpServerConnection
createEntityDeserializer, createEntitySerializer, createHttpRequestFactory, createRequestParser, createResponseWriter, doFlush, flush, getMetrics, init, isStale, receiveRequestEntity, receiveRequestHeader, sendResponseEntity, sendResponseHeader
-
Constructor Details
-
SocketHttpServerConnection
public SocketHttpServerConnection()
-
-
Method Details
-
assertNotOpen
protected void assertNotOpen() -
assertOpen
protected void assertOpen()- Specified by:
assertOpenin classAbstractHttpServerConnection
-
createHttpDataReceiver
protected SessionInputBuffer createHttpDataReceiver(Socket socket, int buffersize, HttpParams params) throws IOException- Throws:
IOException
-
createHttpDataTransmitter
protected SessionOutputBuffer createHttpDataTransmitter(Socket socket, int buffersize, HttpParams params) throws IOException- Throws:
IOException
-
bind
- Throws:
IOException
-
getSocket
-
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.
-
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
-