Package com.ensea_chatapp_tcp.Server
Class TCPServer
java.lang.Object
com.ensea_chatapp_tcp.Server.TCPServer
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSend message to all clients connected to threadsvoidlaunch()static voidvoidCreate a new connection thread and add it to the connection threads listvoidRemoveConnection(ConnectionThread connection) Remove a connection thread from connection threads listtoString()Returns state of the Server
-
Constructor Details
-
TCPServer
public TCPServer() -
TCPServer
public TCPServer(int listening_port)
-
-
Method Details
-
main
- Throws:
IOException
-
GetServerSocket
-
launch
- Throws:
IOException
-
Echo
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
Remove a connection thread from connection threads list- Parameters:
connection- The connection which should be removed
-
toString
Returns state of the Server
-