private static void QueryPtrCallback(IntPtr h, DnsServiceFlags flags, int ifIndex, DnsServiceErrorType errorCode, string fullName, DnsServiceType rrType, DnsServiceClass rrClass, ushort dataLen, byte[] data, uint ttl, IntPtr context) { Dictionary<string, BonjourDevice> deviceList; lock (lookups) if (!lookups.TryGetValue(context, out deviceList)) return; BonjourDevice device; lock (deviceList) if (!deviceList.TryGetValue(fullName, out device)) return; if (errorCode != DnsServiceErrorType.NoError) { device.Error = errorCode; return; } device.Host.Address = new IPAddress(data); device.IsComplete = true; }
public static extern DnsServiceErrorType DNSServiceQueryRecord( out IntPtr handle, DnsServiceFlags flags, int ifIndex, string fullName, [MarshalAs(UnmanagedType.U2)] DnsServiceType rrType, [MarshalAs(UnmanagedType.U2)] DnsServiceClass rrClass, DnsServiceQueryRecordReply callback, IntPtr context);
private static void QueryPtrCallback(IntPtr h, DnsServiceFlags flags, int ifIndex, DnsServiceErrorType errorCode, string fullName, DnsServiceType rrType, DnsServiceClass rrClass, ushort dataLen, byte[] data, uint ttl, IntPtr context) { Dictionary <string, BonjourDevice> deviceList; lock (lookups) if (!lookups.TryGetValue(context, out deviceList)) { return; } BonjourDevice device; lock (deviceList) if (!deviceList.TryGetValue(fullName, out device)) { return; } if (errorCode != DnsServiceErrorType.NoError) { device.Error = errorCode; return; } device.Host.Address = new IPAddress(data); device.IsComplete = true; }