Пример #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));
 }