- All Superinterfaces:
- SocketContext,- Supplier<byte[]>
- All Known Implementing Classes:
- DirectSocket,- PlainSocket,- TlsSocket
Socket abstraction to allow usage of TLS or even non-socket transport.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close the underlying socket.voididle()Sets the socket to idle mode.booleanCheck if socket is connected.default Stringprotocol()Protocol that was negotiated.default booleanWhether a protocol was negotiated by the socket (such as ALPN when using TLS).intread(BufferData buffer) Read bytes from the socket.voidwrite(BufferData buffer) Write teh buffer to the underlying socket.Methods inherited from interface io.helidon.common.socket.SocketContextchildSocketId, isSecure, localPeer, log, log, remotePeer, socketId
- 
Method Details- 
closevoid close()Close the underlying socket.
- 
idlevoid idle()Sets the socket to idle mode. Idle mode expects no bytes coming over the socket but keeps reading exactly one byte in case connection is severed. Idle mode should be used in case of client side connection caching.
- 
isConnectedboolean isConnected()Check if socket is connected.- Returns:
- true if connected
 
- 
readRead bytes from the socket. This method blocks until at least 1 byte is available.- Parameters:
- buffer- buffer to read to
- Returns:
- number of bytes read
 
- 
writeWrite teh buffer to the underlying socket. This method blocks until all bytes are written.- Parameters:
- buffer- buffer to write
 
- 
protocolNegotiateddefault boolean protocolNegotiated()Whether a protocol was negotiated by the socket (such as ALPN when using TLS).- Returns:
- whether a protocol was negotiated
 
- 
protocolProtocol that was negotiated.- Returns:
- protocol name
- Throws:
- NoSuchElementException- in case there is no negotiated protocol
 
 
-