java.lang.Object
io.helidon.common.socket.PlainSocket
- All Implemented Interfaces:
HelidonSocket
,SocketContext
,Supplier<byte[]>
- Direct Known Subclasses:
TlsSocket
Helidon socket that is based on plaintext.
-
Constructor Summary
ModifierConstructorDescriptionprotected
PlainSocket
(Socket delegate, String childSocketId, String socketId) Plain socket. -
Method Summary
Modifier and TypeMethodDescriptionChild socket id.static PlainSocket
Create a new client socket.void
close()
Close the underlying socket.byte[]
get()
void
idle()
Sets the socket to idle mode.boolean
Check if socket is connected.boolean
isSecure()
Whether the request is secure.Local peer information.int
read
(BufferData buffer) Read bytes from the socket.Remote peer information.static PlainSocket
Create a new server socket.socketId()
Main socket id.void
write
(BufferData buffer) Write teh buffer to the underlying socket.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.common.socket.HelidonSocket
protocol, protocolNegotiated
Methods inherited from interface io.helidon.common.socket.SocketContext
log, log
-
Constructor Details
-
PlainSocket
Plain socket.- Parameters:
delegate
- delegate socketchildSocketId
- channel idsocketId
- server channel id
-
-
Method Details
-
server
Create a new server socket.- Parameters:
delegate
- underlying socketchannelId
- channel idserverChannelId
- server channel id- Returns:
- a new plain socket
-
client
Create a new client socket.- Parameters:
delegate
- underlying socketchannelId
- channel id- Returns:
- a new plain socket
-
remotePeer
Description copied from interface:SocketContext
Remote peer information.- Specified by:
remotePeer
in interfaceSocketContext
- Returns:
- peer info
-
localPeer
Description copied from interface:SocketContext
Local peer information.- Specified by:
localPeer
in interfaceSocketContext
- Returns:
- peer info
-
isSecure
public boolean isSecure()Description copied from interface:SocketContext
Whether the request is secure.- Specified by:
isSecure
in interfaceSocketContext
- Returns:
- whether secure
-
socketId
Description copied from interface:SocketContext
Main socket id. This is the server socket id for server side, connection id for client side.- Specified by:
socketId
in interfaceSocketContext
- Returns:
- socket id
-
childSocketId
Description copied from interface:SocketContext
Child socket id. This is the connection socket id for server side. For client side, this may be additional identification of a request (pipeline id, stream id).- Specified by:
childSocketId
in interfaceSocketContext
- Returns:
- child socket id, never null
-
close
public void close()Description copied from interface:HelidonSocket
Close the underlying socket.- Specified by:
close
in interfaceHelidonSocket
-
idle
public void idle()Description copied from interface:HelidonSocket
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.- Specified by:
idle
in interfaceHelidonSocket
-
isConnected
public boolean isConnected()Description copied from interface:HelidonSocket
Check if socket is connected.- Specified by:
isConnected
in interfaceHelidonSocket
- Returns:
- true if connected
-
read
Description copied from interface:HelidonSocket
Read bytes from the socket. This method blocks until at least 1 byte is available.- Specified by:
read
in interfaceHelidonSocket
- Parameters:
buffer
- buffer to read to- Returns:
- number of bytes read
-
write
Description copied from interface:HelidonSocket
Write teh buffer to the underlying socket. This method blocks until all bytes are written.- Specified by:
write
in interfaceHelidonSocket
- Parameters:
buffer
- buffer to write
-
get
public byte[] get()
-