File tree 4 files changed +24
-4
lines changed
4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,14 @@ static void Main(string[] args)
51
51
}
52
52
} ;
53
53
54
+ #if false
54
55
var sd = new ServiceDiscovery ( mdns ) ;
55
56
sd . Advertise ( new ServiceProfile ( "x1" , "_xservice._tcp" , 5011 ) ) ;
56
57
sd . Advertise ( new ServiceProfile ( "x2" , "_xservice._tcp" , 666 ) ) ;
57
58
var z1 = new ServiceProfile ( "z1" , "_zservice._udp" , 5012 ) ;
58
59
z1 . AddProperty ( "foo" , "bar" ) ;
59
60
sd . Advertise ( z1 ) ;
60
-
61
+ #endif
61
62
mdns . Start ( ) ;
62
63
Console . ReadKey ( ) ;
63
64
}
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ public class MessageEventArgs : EventArgs
24
24
/// The endpoint from the message was received.
25
25
/// </value>
26
26
public IPEndPoint RemoteEndPoint { get ; set ; }
27
+
28
+ /// <summary>
29
+ /// Determines if the sender is using legacy unicast DNS.
30
+ /// </summary>
31
+ /// <value>
32
+ /// <b>false</b> if the sender is using port 5353.
33
+ /// </value>
34
+ public bool IsLegacyUnicast => RemoteEndPoint . Port != MulticastClient . MulticastPort ;
27
35
}
28
36
}
29
37
Original file line number Diff line number Diff line change @@ -19,7 +19,14 @@ class MulticastClient : IDisposable
19
19
{
20
20
static readonly ILog log = LogManager . GetLogger ( typeof ( MulticastClient ) ) ;
21
21
22
- const int MulticastPort = 5353 ;
22
+ /// <summary>
23
+ /// The port number assigned to Multicast DNS.
24
+ /// </summary>
25
+ /// <value>
26
+ /// Port number 5353.
27
+ /// </value>
28
+ public static readonly int MulticastPort = 5353 ;
29
+
23
30
static readonly IPAddress MulticastAddressIp4 = IPAddress . Parse ( "224.0.0.251" ) ;
24
31
static readonly IPAddress MulticastAddressIp6 = IPAddress . Parse ( "FF02::FB" ) ;
25
32
static readonly IPEndPoint MdnsEndpointIp6 = new IPEndPoint ( MulticastAddressIp6 , MulticastPort ) ;
Original file line number Diff line number Diff line change @@ -40,8 +40,12 @@ public void SendQuery()
40
40
mdns . NetworkInterfaceDiscovered += ( s , e ) => ready . Set ( ) ;
41
41
mdns . QueryReceived += ( s , e ) =>
42
42
{
43
- msg = e . Message ;
44
- done . Set ( ) ;
43
+ if ( "some-service.local" == e . Message . Questions . First ( ) . Name )
44
+ {
45
+ msg = e . Message ;
46
+ Assert . IsFalse ( e . IsLegacyUnicast ) ;
47
+ done . Set ( ) ;
48
+ }
45
49
} ;
46
50
try
47
51
{
You can’t perform that action at this time.
0 commit comments