Ejemplo n.º 1
0
        // ================== Public Methods ==================

        public Socket(AddressFamily addressFamily,
                      SocketType socketType,
                      ProtocolType protocolType)
        {
            // We only support TCP streams

            if (addressFamily != AddressFamily.InterNetwork)
            {
                throw new SocketException(SocketErrors.WSAEAFNOSUPPORT);
            }

            if (socketType == SocketType.Stream &&
                protocolType == ProtocolType.Tcp)
            {
                internalSocket = new TcpSocket();
                return;
            }

            if (socketType == SocketType.Dgram &&
                protocolType == ProtocolType.Udp)
            {
                internalSocket = new UdpSocket();
                return;
            }
            throw new SocketException(SocketErrors.WSAEPROTONOSUPPORT);
        }
Ejemplo n.º 2
0
        public Socket Accept()
        {
            InternalSocket s = internalSocket.Accept();

            if (s != null)
            {
                return(new Socket(s));
            }
            return(null);
        }
Ejemplo n.º 3
0
        // ================== Private Methods ==================

        private Socket(InternalSocket internalSocket)
        {
            this.internalSocket = internalSocket;
        }