gvsu/cs654/lab5/partI/ChatServer.java
josh 55e67017fc initial import of provided code
git-svn-id: svn://anubis/gvsu@14 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-02-17 02:56:05 +00:00

26 lines
721 B
Java

import java.net.*;
import java.io.*;
import java.util.*;
public class ChatServer {
public ChatServer (int port) throws IOException {
ServerSocket server = new ServerSocket (port);
while (true) {
Socket client = server.accept();
?
String name = in.readUTF();
System.out.println ("New client "+name+" from " + ?);
ChatHandler c = new ChatHandler (name, client);
c.start ();
}
}
public static void main (String args[]) throws IOException {
if (args.length != 1)
throw new RuntimeException ("Syntax: java ChatServer <port>");
new ChatServer (Integer.parseInt (args[0]));
}
}