|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package xyz.nextn;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.net.Socket;
- import java.net.UnknownHostException;
-
- public class Client {
- private Socket socket = null;
- private DataInputStream input = null;
- private DataOutputStream out = null;
-
- public Client(String address, int port) {
- try {
- socket = new Socket(address, port);
- System.out.println("Connected");
-
-
- input = new DataInputStream(System.in);
-
-
- out = new DataOutputStream(socket.getOutputStream());
- } catch (UnknownHostException u) {
- System.out.println(u);
- } catch (IOException i) {
- System.out.println(i);
- }
-
-
- String line = "";
-
-
- while (!line.equals("Over")) {
- try {
- line = input.readLine();
- out.writeUTF(line);
- } catch (IOException i) {
- System.out.println(i);
- }
- }
-
-
- try {
- input.close();
- out.close();
- socket.close();
- } catch (IOException i) {
- System.out.println(i);
- }
- }
-
- }
|