public void Connect(IPAddress address, int port)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this, address);
if (CleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
if (address == null)
{
throw new ArgumentNullException(nameof(address));
}
if (!TcpValidationHelpers.ValidatePortNumber(port))
{
throw new ArgumentOutOfRangeException(nameof(port));
}
if (!CanTryAddressFamily(address.AddressFamily))
{
throw new NotSupportedException(SR.net_invalidversion);
}
IPEndPoint remoteEP = new IPEndPoint(address, port);
Connect(remoteEP);
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}