Package com.ensea_chatapp_tcp.Server
Class ConnectionThread
java.lang.Object
java.lang.Thread
com.ensea_chatapp_tcp.Server.ConnectionThread
- All Implemented Interfaces:
Runnable
Thread in order to handle clients' connections
The thread listen and accept connection. If a connection is established, another ConnectionThread is instantiated
in order to handle new connections
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrun()The method run in order to start the FetchThread.voidsend_message(String message) Send a message to the client connected to this threadMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, 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, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
ConnectionThread
Constructor- Parameters:
tcpServer- the TCPServer which wraps the ServerSocket
-
-
Method Details
-
send_message
Send a message to the client connected to this thread- Parameters:
message- The message as String- Throws:
IOException
-
run
public void run()The method run in order to start the FetchThread. This is going to accept a connection In case a connection is establsihed, the tcpServer will make new Connection. Then this connection will fetch data from client. In case the data is available, it will echo the data and sender's ip
-