-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathClientThread.java
More file actions
63 lines (57 loc) · 1.08 KB
/
ClientThread.java
File metadata and controls
63 lines (57 loc) · 1.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Server;
import java.io.DataInputStream;
import java.net.Socket;
import Client.SmallTalkClient;
public class ClientThread extends Thread{
private Socket socket = null;
private SmallTalkClient client = null;
private DataInputStream streamIn = null;
/*
* Constructor for ClientThread
*/
public ClientThread(SmallTalkClient client, Socket socket){
this.client = client;
this.socket = socket;
open();
start();
}
/*
* Opens the stream in to receive information from the socket
*/
public void open(){
try{
streamIn = new DataInputStream(socket.getInputStream());
}catch(Exception e){
e.printStackTrace();
}
}
/*
* Closes the stream
*/
public void close(){
try{
if(streamIn != null)
streamIn.close();
}catch(Exception e){
e.printStackTrace();
}
}
/*
* (non-Javadoc)
* @see java.lang.Thread#run()
*/
public void run(){
while(true){
try{
System.out.println("running");
}catch(Exception e){
e.printStackTrace();
try {
client.stop();
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
}