import java.io.*; import java.net.*; public class Node { public static void main(String[] args) { if(args.length == 2) { Server s = new Server(Integer.parseInt(args[0]),Integer.parseInt(args[1])); s.startListening(); } else if(args.length == 4) { Client c = new Client(Integer.parseInt(args[0]),args[1],Integer.parseInt(args[2]),args[3]); c.connect(); } else { System.err.println("\nUsage (Server): java Node "); System.err.println("Usage (Client): java Node \n"); System.err.println("Note: Only ports 9000-9060 may be used on DCS machines\n"); System.exit(-1); } } } class Server { ServerSocket myserver = null; Socket myclient = null; Server(int port, int clients){ startListening(port); } // start server socket on port PORT, listen for CLIENTS // maybe error if cant listen // for each client create a client socket and bind addresses myclient = myserver.accept(); public void startListening(int port) { myserver = new ServerSocket(9000); } } class Client { Socket clientsocket = null; String status = null; int id = null; Client(int id, String host, int port, String status) { this.id = id; this.status = status; connect(host, port); } public void connect(String host, int port) { clientsocket = new Socket(host, port); } }