1 //------------------------------------------------------------------------------
2 // <copyright file="UDPClient.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
7 namespace System.Net.Sockets
9 using System.Threading;
10 using System.Threading.Tasks;
11 using System.Security.Permissions;
12 using System.Diagnostics.CodeAnalysis;
14 public struct UdpReceiveResult : IEquatable<UdpReceiveResult>
16 private byte[] m_buffer;
17 private IPEndPoint m_remoteEndPoint;
19 public UdpReceiveResult(byte[] buffer, IPEndPoint remoteEndPoint)
23 throw new ArgumentNullException("buffer");
26 if (remoteEndPoint == null)
28 throw new ArgumentNullException("remoteEndPoint");
32 m_remoteEndPoint = remoteEndPoint;
35 [SuppressMessage("Microsoft.Performance","CA1819:PropertiesShouldNotReturnArrays",
36 Justification="This is merely strongly type data aggregation")]
45 public IPEndPoint RemoteEndPoint
49 return m_remoteEndPoint;
53 public override int GetHashCode()
55 return (m_buffer != null) ? (m_buffer.GetHashCode() ^ m_remoteEndPoint.GetHashCode()) : 0;
58 public override bool Equals(object obj)
60 if (!(obj is UdpReceiveResult))
65 return Equals((UdpReceiveResult)obj);
68 public bool Equals(UdpReceiveResult other)
70 return object.Equals(this.m_buffer, other.m_buffer) && object.Equals(this.m_remoteEndPoint, other.m_remoteEndPoint);
73 public static bool operator ==(UdpReceiveResult left, UdpReceiveResult right)
75 return left.Equals(right);
78 public static bool operator !=(UdpReceiveResult left, UdpReceiveResult right)
80 return !left.Equals(right);