public NetworkStream(Socket socket, FileAccess access)
        {
            _socket = socket.ThrowIfNull("socket");

            if (_socket.ProtocolType != ProtocolType.Tcp)
            {
                throw new ArgumentException("socket protocol type must be tcp.");
            }

            if (!_socket.Connected)
            {
                throw new IOException("socket is not connected");
            }

            _readable = access.HasFlag(FileAccess.Read);
            _writeable = access.HasFlag(FileAccess.Write);
        }
Example #2
0
        public NetworkStream(Socket socket, FileAccess access)
        {
            _socket = socket.ThrowIfNull("socket");

            if (_socket.ProtocolType != ProtocolType.Tcp)
            {
                throw new ArgumentException("socket protocol type must be tcp.");
            }

            if (!_socket.Connected)
            {
                throw new IOException("socket is not connected");
            }

            _readable  = access.HasFlag(FileAccess.Read);
            _writeable = access.HasFlag(FileAccess.Write);
        }