Class TCPServer

java.lang.Object
com.ensea_chatapp_tcp.Server.TCPServer

public class TCPServer extends Object
This is a class to implement a chat app TCP Server

The class takes an optional command line arguments: Server port In the case that port is absent, 8439 is the default port.

Usage: java com.ensea_chatapp_tcp.Server.TCPServer

Usage: java com.ensea_chatapp_tcp.Server.TCPServer server_port

  • Constructor Details

    • TCPServer

      public TCPServer()
    • TCPServer

      public TCPServer(int listening_port)
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • GetServerSocket

      public ServerSocket GetServerSocket()
    • launch

      public void launch() throws IOException
      Throws:
      IOException
    • Echo

      public void Echo(String message) throws IOException
      Send message to all clients connected to threads
      Parameters:
      message - The message as String
      Throws:
      IOException
    • NewConnection

      public void NewConnection()
      Create a new connection thread and add it to the connection threads list
    • RemoveConnection

      public void RemoveConnection(ConnectionThread connection)
      Remove a connection thread from connection threads list
      Parameters:
      connection - The connection which should be removed
    • toString

      public String toString()
      Returns state of the Server
      Overrides:
      toString in class Object
      Returns:
      State of server in String