Package io.activej.net.socket.tcp
Interface ITcpSocket
- All Superinterfaces:
AsyncCloseable
- All Known Implementing Classes:
SslTcpSocket,TcpSocket
Common interface for connection-oriented transport protocols.
This interface describes asynchronous read and write operations for data transmission through the network.
Implementations of this interface should follow rules described below:
- Each request to the socket after it was closed should complete exceptionally. This is due to an ability of
the socket to be closed before any read/write operation is called. User should be informed about it after he makes first
call to
read()orwrite(ByteBuf)
-
Field Summary
Fields inherited from interface io.activej.async.process.AsyncCloseable
STATIC -
Method Summary
Methods inherited from interface io.activej.async.process.AsyncCloseable
close, closeEx
-
Method Details
-
read
Operation to read some data from network. Returns a promise of a bytebuf that represents some data received from network.It is allowed to call read before previous read was completed. However, each consecutive call will cancel all the previous calls (they will not be completed).
- Returns:
- promise of ByteBuf that represents data received from network
-
write
Operation to write some data to network. Returns a promise of void that represents successful write.Many write operations may be called. However, when some write is successful, all the promises received from write calls before it will be completed at once.
- Parameters:
buf- data to be sent to network- Returns:
- promise that represents successful write operation
-
isReadAvailable
boolean isReadAvailable() -
isClosed
boolean isClosed()
-