- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecvThread.java
More file actions
Latest commit
executable file
·39 lines (34 loc) · 1.04 KB
/
Copy pathRecvThread.java
File metadata and controls
executable file
·39 lines (34 loc) · 1.04 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
importjava.io.IOException;
importjava.net.SocketTimeoutException;
importjava.util.Date;
publicclassRecvThreadextendsThread {
publicSocketDemosocketDemo;
privatestaticinttimeoutCount = 0;
publicvoidrun(){
while (this.socketDemo.myQuitSignal == false){
try {
intreadCount = this.socketDemo.myReader.read(
this.socketDemo.myRecv, this.socketDemo.myRecvIndicator,
this.socketDemo.myRecvCount - this.socketDemo.myRecvIndicator - 1);
if (readCount > 0) {
this.socketDemo.myRecvIndicator += readCount;
this.socketDemo.processData();
}
timeoutCount = 0;
} catch (SocketTimeoutExceptione) {
if (timeoutCount > 5) {
this.socketDemo.myQuitSignal = true;
this.socketDemo.myQuitDate = newDate();
timeoutCount = 0;
return;
}
continue;
} catch (Exceptione) {
e.printStackTrace();
this.socketDemo.myQuitSignal = true;
this.socketDemo.myQuitDate = newDate();
return;
}
}
}
}