|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SocketService.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Created on 2004/06/04
|
|
3 |
*/
|
|
4 |
package org.asyrinx.brownie.net.socket;
|
|
5 |
|
|
6 |
import java.io.IOException;
|
|
7 |
|
|
8 |
import org.apache.commons.logging.Log;
|
|
9 |
import org.apache.commons.logging.LogFactory;
|
|
10 |
|
|
11 |
/**
|
|
12 |
* @author akima
|
|
13 |
*/
|
|
14 |
public class SocketService implements Runnable { |
|
15 |
/**
|
|
16 |
*
|
|
17 |
*/
|
|
18 | 0 |
public SocketService(SocketServerListener listener) {
|
19 | 0 |
super();
|
20 | 0 |
this.listener = listener;
|
21 |
} |
|
22 |
|
|
23 |
public static final int DEFAULT_PORT = 5555; |
|
24 |
|
|
25 |
private final SocketServerListener listener;
|
|
26 |
|
|
27 |
private int port = DEFAULT_PORT; |
|
28 |
|
|
29 |
private final Log log = LogFactory.getLog(this.getClass()); |
|
30 |
|
|
31 |
private boolean running = false; |
|
32 |
|
|
33 |
/*
|
|
34 |
* (non-Javadoc)
|
|
35 |
*
|
|
36 |
* @see java.lang.Runnable#run()
|
|
37 |
*/
|
|
38 | 0 |
public void run() { |
39 | 0 |
while (running) {
|
40 | 0 |
final SocketServer server = new SocketServer(listener, this.port); |
41 | 0 |
try {
|
42 | 0 |
server.receive(); |
43 |
} catch (IOException e) {
|
|
44 | 0 |
log.error("", e);
|
45 | 0 |
running = false;
|
46 |
} |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 | 0 |
public void start() { |
51 |
//do nothing
|
|
52 |
} |
|
53 |
|
|
54 | 0 |
public void stop() { |
55 | 0 |
running = false;
|
56 |
|
|
57 |
} |
|
58 |
} |
|