Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.*;
- public class EchoClient {
- public static PrintWriter out;
- public static void main(String[] args) throws IOException {
- if (args.length != 2) {
- System.err.println(
- "Usage: java EchoClient <host name> <port number>");
- System.exit(1);
- }
- String hostName = args[0];
- int portNumber = Integer.parseInt(args[1]);
- try (
- Socket echoSocket = new Socket(hostName, portNumber);
- PrintWriter out =
- new PrintWriter(echoSocket.getOutputStream(), true);
- BufferedReader in =
- new BufferedReader(
- new InputStreamReader(echoSocket.getInputStream()));
- BufferedReader stdIn =
- new BufferedReader(
- new InputStreamReader(System.in));
- ) {
- admin t = new admin("repeat","12345678");
- //t.sendTest("\005TST\000!");
- t.connectToChat();
- /*
- String userInput;
- while ((userInput = stdIn.readLine()) != null) {
- out.println(userInput);
- System.out.println("echo: " + in.readLine());
- }
- */
- } catch (UnknownHostException e) {
- System.err.println("Don't know about host " + hostName);
- System.exit(1);
- } catch (IOException e) {
- System.err.println("Couldn't get I/O for the connection to " +
- hostName);
- System.exit(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment