internal void InternalBind(EndPoint localEP)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this, localEP);
if (CleanedUp)
{
throw new ObjectDisposedException(GetType().FullName);
}
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"localEP:{localEP}");
if (localEP is DnsEndPoint)
{
NetEventSource.Fail(this, "Calling InternalBind with a DnsEndPoint, about to get NotImplementedException");
}
// Ask the EndPoint to generate a SocketAddress that we can pass down to native code.
EndPoint endPointSnapshot = localEP;
Internals.SocketAddress socketAddress = SnapshotAndSerialize(ref endPointSnapshot);
DoBind(endPointSnapshot, socketAddress);
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}