Package org.omegazero.http.netutil
Class SocketConnectionWritable
java.lang.Object
org.omegazero.http.netutil.SocketConnectionWritable
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,WritableSocket
A
WritableSocket
that wraps a SocketConnection
.-
Constructor Summary
ConstructorsConstructorDescriptionSocketConnectionWritable
(org.omegazero.net.socket.SocketConnection connection) Creates a newSocketConnectionWritable
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes thisWritableSocket
.void
flush()
Flushes any remaining data in thisWritableSocket
's write buffer.org.omegazero.net.socket.SocketConnection
Returns theSocketConnection
passed in the constructor.Returns a readable string identifier of the remote peer.boolean
Returnstrue
if thisWritableSocket
is connected, meaning data can still be written.boolean
Returnstrue
if thisWritableSocket
is writable.void
write
(byte[] data, int offset, int length) Writes the given data to thisWritableSocket
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.omegazero.http.util.WritableSocket
write
-
Constructor Details
-
SocketConnectionWritable
public SocketConnectionWritable(org.omegazero.net.socket.SocketConnection connection) Creates a newSocketConnectionWritable
.- Parameters:
connection
- The connection to write to
-
-
Method Details
-
write
public void write(byte[] data, int offset, int length) Description copied from interface:WritableSocket
Writes the given data to thisWritableSocket
.- Specified by:
write
in interfaceWritableSocket
- Parameters:
data
- The dataoffset
- The index to start writing fromlength
- The number of bytes to write, starting at offset- See Also:
-
flush
public void flush()Description copied from interface:WritableSocket
Flushes any remaining data in thisWritableSocket
's write buffer.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceWritableSocket
-
isConnected
public boolean isConnected()Description copied from interface:WritableSocket
Returnstrue
if thisWritableSocket
is connected, meaning data can still be written. This is distinct fromWritableSocket.isWritable()
because a socket may still be connected, while not being writable, because data is backed up locally.- Specified by:
isConnected
in interfaceWritableSocket
- Returns:
true
if thisWritableSocket
is connected- See Also:
-
isWritable
public boolean isWritable()Description copied from interface:WritableSocket
Returnstrue
if thisWritableSocket
is writable. A socket is writable if data can be written without requiring this data to be buffered locally, potentially causing excessive memory consumption.- Specified by:
isWritable
in interfaceWritableSocket
- Returns:
true
if thisWritableSocket
is writable- See Also:
-
getRemoteName
Description copied from interface:WritableSocket
Returns a readable string identifier of the remote peer.- Specified by:
getRemoteName
in interfaceWritableSocket
- Returns:
- A readable remote string identifier
-
close
public void close()Description copied from interface:WritableSocket
Closes thisWritableSocket
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceWritableSocket
-
getConnection
public org.omegazero.net.socket.SocketConnection getConnection()Returns theSocketConnection
passed in the constructor.- Returns:
- The
SocketConnection
-