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