예제 #1
0
 public static bool IsEndPointEmpty(this Datagram datagram)
 {
     return(datagram.Address.IsEmpty && datagram.Port == 0);
 }
예제 #2
0
 public static Try <Datagram> AsTry(this Datagram datagram)
 {
     return(new Try <Datagram>(datagram));
 }
예제 #3
0
 public static IPAddress GetAddress(this Datagram datagram)
 {
     return(new IPAddress(datagram.Address.Span));
 }
예제 #4
0
 public static Datagram WithBuffer(this Datagram datagram, ReadOnlyMemory <byte> buffer)
 {
     return(new Datagram(buffer, datagram.Address, datagram.Port));
 }
예제 #5
0
 public static IPEndPoint GetEndPoint(this Datagram datagram)
 {
     return(new IPEndPoint(new IPAddress(datagram.Address.Span), datagram.Port));
 }
예제 #6
0
 public static Datagram WithAddress(this Datagram datagram, string ipString)
 {
     return(datagram.WithAddress(IPAddress.Parse(ipString)));
 }
예제 #7
0
 public static Datagram WithAddress(this Datagram datagram, params byte[] ipBytes)
 {
     return(datagram.WithAddress(new IPAddress(ipBytes)));
 }
예제 #8
0
 public static Datagram WithAddress(this Datagram datagram, IPAddress ipAddress)
 {
     return(new Datagram(datagram.Buffer, ipAddress.GetAddressBytes(), datagram.Port));
 }
예제 #9
0
 public static Datagram WithEndPoint(this Datagram datagram, IPEndPoint endPoint)
 {
     return(new Datagram(datagram.Buffer, endPoint.Address.GetAddressBytes(), endPoint.Port));
 }