|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SocketListener | Line # 17 | 29 | 0% | 21 | 16 | 68% |
0.68
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(21) | |||
Result | |||
0.68
|
javax.jmdns.test.TextUpdateTest.testSubtype
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
![]() |
1 PASS | |
0.68
|
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testUnregisterService
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testRegisterServiceTwice
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testRegisterService
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListMyService
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testQueryMyService
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
![]() |
1 PASS | |
0.64
|
javax.jmdns.test.JmDNSTest.testListenForMyService
![]() |
1 PASS | |
0.34
|
javax.jmdns.test.JmDNSTest.testCreate
![]() |
1 PASS | |
0.34
|
javax.jmdns.test.JmDNSTest.testCreateINet
![]() |
1 PASS | |
1 | // Copyright 2003-2005 Arthur van Hoff, Rick Blair | |
2 | // Licensed under Apache License version 2.0 | |
3 | // Original license LGPL | |
4 | ||
5 | package javax.jmdns.impl; | |
6 | ||
7 | import java.io.IOException; | |
8 | import java.net.DatagramPacket; | |
9 | import java.util.logging.Level; | |
10 | import java.util.logging.Logger; | |
11 | ||
12 | import javax.jmdns.impl.constants.DNSConstants; | |
13 | ||
14 | /** | |
15 | * Listen for multicast packets. | |
16 | */ | |
17 | class SocketListener extends Thread { | |
18 | static Logger logger = Logger.getLogger(SocketListener.class.getName()); | |
19 | ||
20 | /** | |
21 | * | |
22 | */ | |
23 | private final JmDNSImpl _jmDNSImpl; | |
24 | ||
25 | /** | |
26 | * @param jmDNSImpl | |
27 | */ | |
28 | 29 |
![]() |
29 | 29 | super("SocketListener(" + (jmDNSImpl != null ? jmDNSImpl.getName() : "") + ")"); |
30 | 29 | this.setDaemon(true); |
31 | 29 | this._jmDNSImpl = jmDNSImpl; |
32 | } | |
33 | ||
34 | 29 |
![]() |
35 | public void run() { | |
36 | 29 | try { |
37 | 29 | byte buf[] = new byte[DNSConstants.MAX_MSG_ABSOLUTE]; |
38 | 29 | DatagramPacket packet = new DatagramPacket(buf, buf.length); |
39 | 673 | while (!this._jmDNSImpl.isCanceling() && !this._jmDNSImpl.isCanceled()) { |
40 | 679 | packet.setLength(buf.length); |
41 | 682 | this._jmDNSImpl.getSocket().receive(packet); |
42 | 652 | if (this._jmDNSImpl.isCanceling() || this._jmDNSImpl.isCanceled() || this._jmDNSImpl.isClosing() || this._jmDNSImpl.isClosed()) { |
43 | 16 | break; |
44 | } | |
45 | 637 | try { |
46 | 638 | if (this._jmDNSImpl.getLocalHost().shouldIgnorePacket(packet)) { |
47 | 0 | continue; |
48 | } | |
49 | ||
50 | 644 | DNSIncoming msg = new DNSIncoming(packet); |
51 | 640 | if (logger.isLoggable(Level.FINEST)) { |
52 | 0 | logger.finest(this.getName() + ".run() JmDNS in:" + msg.print(true)); |
53 | } | |
54 | 647 | if (msg.isQuery()) { |
55 | 339 | if (packet.getPort() != DNSConstants.MDNS_PORT) { |
56 | 0 | this._jmDNSImpl.handleQuery(msg, packet.getAddress(), packet.getPort()); |
57 | } | |
58 | 336 | this._jmDNSImpl.handleQuery(msg, this._jmDNSImpl.getGroup(), DNSConstants.MDNS_PORT); |
59 | } else { | |
60 | 298 | this._jmDNSImpl.handleResponse(msg); |
61 | } | |
62 | } catch (IOException e) { | |
63 | 0 | logger.log(Level.WARNING, this.getName() + ".run() exception ", e); |
64 | } | |
65 | } | |
66 | } catch (IOException e) { | |
67 | 13 | if (!this._jmDNSImpl.isCanceling() && !this._jmDNSImpl.isCanceled() && !this._jmDNSImpl.isClosing() && !this._jmDNSImpl.isClosed()) { |
68 | 0 | logger.log(Level.WARNING, this.getName() + ".run() exception ", e); |
69 | 0 | this._jmDNSImpl.recover(); |
70 | } | |
71 | } | |
72 | 29 | if (logger.isLoggable(Level.FINEST)) { |
73 | 0 | logger.finest(this.getName() + ".run() exiting."); |
74 | } | |
75 | } | |
76 | ||
77 | 0 |
![]() |
78 | 0 | return _jmDNSImpl; |
79 | } | |
80 | ||
81 | } |
|