Class ConnectionThread

java.lang.Object
java.lang.Thread
com.ensea_chatapp_tcp.Server.ConnectionThread
All Implemented Interfaces:
Runnable

public class ConnectionThread extends Thread
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
  • Constructor Details

    • ConnectionThread

      public ConnectionThread(TCPServer tcpServer)
      Constructor
      Parameters:
      tcpServer - the TCPServer which wraps the ServerSocket
  • Method Details

    • send_message

      public void send_message(String message) throws IOException
      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
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread