Class KSocketServerThread
java.lang.Object
java.lang.Thread
ch.k43.util.KSocketServerThread
- All Implemented Interfaces:
AutoCloseable
,Runnable
- Direct Known Subclasses:
KSocketServerThreadSample
Class to handle user connections accepted by KSocketServerListener.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the socket connection.Return name of authenticated client based on the used client certificate.Return common name (without CN=) of the DN (distinguished name) from the used client certificate.Return used TCP cipher suite (Example: "TLS_AES_256_GCM_SHA384").Return last error.Return used TCP connection protocol (Example: "TLSv1.3").boolean
Return connection state.boolean
Check if data is available without blocking.boolean
Check if connection is TLS secured.int
read
(char[] argData) Read socket into character array.readLine()
Read line from socket.void
run()
Main thread entry point - Will be overwritten by user class.toString()
String representation of object.boolean
write
(byte[] argData) Write byte array to socket.boolean
write
(char[] argData) Write character array to socket.boolean
Write string to socket.boolean
Write line terminated with a platform dependent end-of-line to socket.Methods inherited from class java.lang.Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, yield
-
Method Details
-
close
-
getAuthenticatedClient
Return name of authenticated client based on the used client certificate.- Returns:
- DN name of peer principal or null if not TLS authenticated
- Since:
- 2024.05.17
-
getAuthenticatedClientCN
Return common name (without CN=) of the DN (distinguished name) from the used client certificate.- Returns:
- Common name of peer principal or null if not TLS authenticated
- Since:
- 2024.05.17
-
getCiphers
Return used TCP cipher suite (Example: "TLS_AES_256_GCM_SHA384").- Returns:
- TLS cipher suite or null
-
getLastError
-
getProtocol
Return used TCP connection protocol (Example: "TLSv1.3").- Returns:
- TLS protocol used or null
-
isConnected
public boolean isConnected()Return connection state.- Returns:
- True if connected, false otherwise
-
isDataAvailable
public boolean isDataAvailable()Check if data is available without blocking.- Returns:
- True if data is available, false otherwise
-
isSecuredConnection
public boolean isSecuredConnection()Check if connection is TLS secured.- Returns:
- True if connection is TLS secured, false otherwise
-
read
public int read(char[] argData) Read socket into character array.- Parameters:
argData
- Character buffer- Returns:
- Number of bytes read or -1
-
readLine
-
run
-
write
public boolean write(byte[] argData) Write byte array to socket.- Parameters:
argData
- Byte array to be written- Returns:
- True if successful, false otherwise
-
write
public boolean write(char[] argData) Write character array to socket.- Parameters:
argData
- Character array to be written- Returns:
- True if successful, false otherwise
-
write
Write string to socket.- Parameters:
argLine
- String to be written- Returns:
- True if successful, false otherwise
-
writeLine
Write line terminated with a platform dependent end-of-line to socket.- Parameters:
argLine
- String to be written- Returns:
- True if successful, false otherwise
- Since:
- 2024.05.25
-
toString
-