public Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this, addressFamily);
InitializeSockets();
SocketError errorCode = SocketPal.CreateSocket(addressFamily, socketType, protocolType, out _handle);
if (errorCode != SocketError.Success)
{
Debug.Assert(_handle.IsInvalid);
// Failed to create the socket, throw.
throw new SocketException((int)errorCode);
}
Debug.Assert(!_handle.IsInvalid);
_addressFamily = addressFamily;
_socketType = socketType;
_protocolType = protocolType;
// TODO: Investigate this problematic assertion: Issue #4500.
// Debug.Assert(addressFamily != AddressFamily.InterNetworkV6 || !DualMode);
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}