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 TypeMethodDescriptionvoidclose()Closes thisWritableSocket.voidflush()Flushes any remaining data in thisWritableSocket's write buffer.org.omegazero.net.socket.SocketConnectionReturns theSocketConnectionpassed in the constructor.Returns a readable string identifier of the remote peer.booleanReturnstrueif thisWritableSocketis connected, meaning data can still be written.booleanReturnstrueif thisWritableSocketis writable.voidwrite(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, waitMethods 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:WritableSocketWrites the given data to thisWritableSocket.- Specified by:
writein 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:WritableSocketFlushes any remaining data in thisWritableSocket's write buffer.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceWritableSocket
-
isConnected
public boolean isConnected()Description copied from interface:WritableSocketReturnstrueif thisWritableSocketis 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:
isConnectedin interfaceWritableSocket- Returns:
trueif thisWritableSocketis connected- See Also:
-
isWritable
public boolean isWritable()Description copied from interface:WritableSocketReturnstrueif thisWritableSocketis 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:
isWritablein interfaceWritableSocket- Returns:
trueif thisWritableSocketis writable- See Also:
-
getRemoteName
Description copied from interface:WritableSocketReturns a readable string identifier of the remote peer.- Specified by:
getRemoteNamein interfaceWritableSocket- Returns:
- A readable remote string identifier
-
close
public void close()Description copied from interface:WritableSocketCloses thisWritableSocket.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceWritableSocket
-
getConnection
public org.omegazero.net.socket.SocketConnection getConnection()Returns theSocketConnectionpassed in the constructor.- Returns:
- The
SocketConnection
-