package Server; import java.net.*; import java.io.*; import java.util.LinkedList; public class ChatServer { private ServerSocket service; private LinkedList connections; public static final int portNum = 6667; ChatServer() throws IOException { this.service = new ServerSocket(portNum); this.connections = new LinkedList(); } /** Listening to port and opening a socket */ public static void main(String[] args) throws IOException { ChatServer server; try { server = new ChatServer(); } catch (IOException e) { System.err.println("Failed listening on port " + portNum + " (" + e + ")"); return; } Socket soc = null; try { while (true) { soc = server.service.accept(); Connection con = new Connection(soc); server.connections.add(con); con.start(); } } catch (IOException e) { System.out.println(e); } } }