System.Net.Sockets.Socket.Socket C# (CSharp) Method

Socket() public method

public Socket ( AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType ) : System.Collections.Generic
addressFamily AddressFamily
socketType SocketType
protocolType ProtocolType
return System.Collections.Generic
        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);
        }

Same methods

Socket::Socket ( SafeCloseSocket fd ) : System.Collections.Generic
Socket::Socket ( SocketInformation socketInformation ) : System.Collections.Generic
Socket::Socket ( SocketType socketType, ProtocolType protocolType ) : System.Collections.Generic