-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client.java
46 lines (41 loc) · 862 Bytes
/
Client.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package DCCN;
import java.net.*;
import java.io.*;
public class Client {
private Socket socket = null;
private DataInputStream input = null;
private DataOutputStream out = null;
@SuppressWarnings("deprecation")
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(Exception e) {};
String line = "";
while(!line.equals("Over"))
{
try
{
line = input.readLine();
out.writeUTF(line);
}
catch(Exception e) {};
}
try
{
input.close();
out.close();
socket.close();
}
catch(Exception e) {};
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Client client = new Client("127.0.0.1", 5000);
}
}