Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.net.*;
- import java.io.*;
- public class ChatClient
- {
- public ChatClient()
- {
- scanner = new Scanner(System.in);
- }
- public void run()
- {
- // Put console I/O code here, using scanner and System.out
- try
- {
- Socket socket = new Socket("192.168.1.149", 27789);
- PrintWriter writer = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(
- socket.getOutputStream())));
- writer.println("We are all just pale Africans.");
- String message = "NULL";
- message = scanner.nextLine();
- writer.println(message);
- while(message != "quit")
- {
- message = scanner.nextLine();
- writer.println(message);
- }
- writer.flush();
- writer.close();
- socket.close();
- }
- catch (IOException ex)
- {
- System.out.println(ex.getMessage());
- }
- }
- private Scanner scanner;
- public static void main(String[] args)
- {
- ChatClient program = new ChatClient();
- program.run();
- }
- }
Add Comment
Please, Sign In to add comment