public class Server { private ServerSocket ss; private Socket socket; private BufferedReader in; private PrintWriter out;
public Server() { try { ss = new ServerSocket(10000);
while (true) { socket = ss.accept(); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(),true);
public class Client { Socket socket; BufferedReader in; PrintWriter out;
public Client() { try { socket = new Socket("xxx.xxx.xxx.xxx", 10000); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(),true); BufferedReader line = new BufferedReader(new InputStreamReader(System.in));
public CreateServerThread(Socket s) throws IOException { client = s;
in = new BufferedReader(new InputStreamReader(client.getInputStream(), "GB2312")); out = new PrintWriter(client.getOutputStream(), true); out.println("--- Welcome ---"); start(); }
public void run() { try { String line = in.readLine();
while (!line.equals("bye")) { String msg = createMessage(line); out.println(msg); line = in.readLine(); } out.println("--- See you, bye! ---"); client.close(); } catch (IOException e) {} }
public CreateServerThread(Socket s) throws IOException { client = s; in = new BufferedReader(new InputStreamReader(client.getInputStream())); out = new PrintWriter(client.getOutputStream(), true); out.println("--- Welcome to this chatroom ---"); out.println("Input your nickname:"); start(); }
public void sendMessage(String msg) { out.println(msg); }
public void run() { try { int flag = 0; Thread_Counter++; String line = in.readLine();
while (!line.equals("bye")) { if (line.equals("l")) { out.println(listOnlineUsers()); line = in.readLine(); continue; }
if (flag++ == 0) { Username = line; User_List.add(Username); out.println(listOnlineUsers()); Threader.add(this); pushMessage("[< " + Username + " come on in >]"); } else { pushMessage("<" + Username + ">" + line); }
public class Server { private ServerSocket ss; private Socket socket; private BufferedReader in; private PrintWriter out;
public Server() { try { ss = new ServerSocket(10000);
while (true) { socket = ss.accept(); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(),true);
public class Client { Socket socket; BufferedReader in; PrintWriter out;
public Client() { try { socket = new Socket("xxx.xxx.xxx.xxx", 10000); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(),true); BufferedReader line = new BufferedReader(new InputStreamReader(System.in));
public CreateServerThread(Socket s) throws IOException { client = s;
in = new BufferedReader(new InputStreamReader(client.getInputStream(), "GB2312")); out = new PrintWriter(client.getOutputStream(), true); out.println("--- Welcome ---"); start(); }
public void run() { try { String line = in.readLine();
while (!line.equals("bye")) { String msg = createMessage(line); out.println(msg); line = in.readLine(); } out.println("--- See you, bye! ---"); client.close(); } catch (IOException e) {} }
public CreateServerThread(Socket s) throws IOException { client = s; in = new BufferedReader(new InputStreamReader(client.getInputStream())); out = new PrintWriter(client.getOutputStream(), true); out.println("--- Welcome to this chatroom ---"); out.println("Input your nickname:"); start(); }
public void sendMessage(String msg) { out.println(msg); }
public void run() { try { int flag = 0; Thread_Counter++; String line = in.readLine();
while (!line.equals("bye")) { if (line.equals("l")) { out.println(listOnlineUsers()); line = in.readLine(); continue; }
if (flag++ == 0) { Username = line; User_List.add(Username); out.println(listOnlineUsers()); Threader.add(this); pushMessage("[< " + Username + " come on in >]"); } else { pushMessage("<" + Username + ">" + line); }