This Java code defines a simple TCP server, InitServer
, utilizing the ServerSocket
class to handle incoming client connections. The server supports a multi-threaded architecture with an ExecutorService
managing a fixed pool of threads. The main method presents a menu allowing the user to either start the server or exit the program. The server, upon initiation, prompts the user to manually input a port number or generate a random one within a specified range. The startServer
method establishes a server socket, listens for incoming client connections, and delegates each connection to a separate thread (ClientHandler
) for concurrent handling. The ClientHandler
class, implemented as an inner class, manages communication with individual clients by reading and broadcasting messages to all connected clients. The server logs relevant information using the Logger
class.
punkerghoul / servidorsockettcp Goto Github PK
View Code? Open in Web Editor NEWThe Java code defines a TCP server with a basic console menu, supporting manual or random port input, handling multiple client connections using multi-threading, and logging relevant information.
License: GNU General Public License v3.0