|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.simpleframework.transport.SocketTransport
public class SocketTransport
The SocketTransport object offers a transport that can
send and receive bytes in a non-blocking manner. The contract of
the Transport is that it must either write the data
it is asked to write or it must queue that data for delivery. For
the vast majority of cases data is written directly to the socket
without any need for queuing or selection for write ready events.
In the event that the client TCP window is full and writing would block this makes use of a queue of buffers which can be used to append data to. The buffers are lazily instantiated so the memory required is created only in the rare case that they are needed. Once a buffer is full it is queued to an asynchronous thread where the buffer queue is drained and sent to the client when the TCP window of the client is capable of accepting it.
In order to improve the network performance of this transport the default packet size sent to the TCP stack is four kilobytes. This ensures that the fragments of response delivered to the TCP layer are sufficiently large for optimum network performance.
| Constructor Summary | |
|---|---|
SocketTransport(Socket socket,
Reactor reactor)
Constructor for the SocketTransport object. |
|
SocketTransport(Socket socket,
Reactor reactor,
int buffer)
Constructor for the SocketTransport object. |
|
SocketTransport(Socket socket,
Reactor reactor,
int buffer,
int threshold)
Constructor for the SocketTransport object. |
|
| Method Summary | |
|---|---|
void |
close()
This method is used to flush the internal buffer and close the underlying socket. |
void |
flush()
This is used to flush the internal buffer to the underlying socket. |
Map |
getAttributes()
This method is used to get the Map of attributes
by this pipeline. |
Certificate |
getCertificate()
This is used to acquire the SSL certificate used when the server is using a HTTPS connection. |
SocketChannel |
getChannel()
This method is used to acquire the SocketChannel
for the connection. |
SSLEngine |
getEngine()
This is used to acquire the SSL engine used for https. |
Trace |
getTrace()
This is used to acquire the trace object that is associated with the socket. |
int |
read(ByteBuffer data)
This is used to perform a non-blocking read on the transport. |
void |
write(ByteBuffer data)
This method is used to deliver the provided buffer of bytes to the underlying transport. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SocketTransport(Socket socket,
Reactor reactor)
throws IOException
SocketTransport object. This
requires a reactor to perform asynchronous writes and also the
pipeline which is used to read and write data. This transport
will use a queue of buffers which are lazily initialized so as
to only allocate the memory on demand.
socket - this is used to read and write the datareactor - this is used to perform asynchronous writes
IOException
public SocketTransport(Socket socket,
Reactor reactor,
int buffer)
throws IOException
SocketTransport object. This
requires a reactor to perform asynchronous writes and also the
pipeline which is used to read and write data. This transport
will use a queue of buffers which are lazily initialized so as
to only allocate the memory on demand.
socket - this is used to read and write the datareactor - this is used to perform asynchronous writesbuffer - this is the size of the output buffer to use
IOException
public SocketTransport(Socket socket,
Reactor reactor,
int buffer,
int threshold)
throws IOException
SocketTransport object. This
requires a reactor to perform asynchronous writes and also the
pipeline which is used to read and write data. This transport
will use a queue of buffers which are lazily initialized so as
to only allocate the memory on demand.
socket - this is used to read and write the datareactor - this is used to perform asynchronous writesbuffer - this is the size of the output buffer to usethreshold - this is the maximum size of the output buffer
IOException| Method Detail |
|---|
public Certificate getCertificate()
getCertificate in interface Transportpublic Trace getTrace()
getTrace in interface Socketpublic Map getAttributes()
Map of attributes
by this pipeline. The attributes map is used to maintain details
about the connection. Information such as security credentials
to client details can be placed within the attribute map.
getAttributes in interface Socketpublic SSLEngine getEngine()
getEngine in interface Socketpublic SocketChannel getChannel()
SocketChannel
for the connection. This allows the server to acquire the input
and output streams with which to communicate. It can also be
used to configure the connection and perform various network
operations that could otherwise not be performed.
getChannel in interface Socket
public int read(ByteBuffer data)
throws IOException
read in interface Transportdata - this is the buffer to append the bytes to
IOException
public void write(ByteBuffer data)
throws IOException
write in interface Transportdata - this is the array of bytes to send to the client
IOException
public void flush()
throws IOException
flush in interface TransportIOException
public void close()
throws IOException
close in interface TransportIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||