Ejemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            Debug.WriteLine("NS Dispose (" + disposing + ")");

            if (disposed)
            {
                return;
            }
            disposed = true;

            readable  = false;
            writeable = false;

            if (disposing)
            {
                if (owns_socket || socket is CrestronClientSocket)
                {
                    var s = socket;
                    if (s != null)
                    {
                        s.Close();
                    }
                }
                socket = null;
                access = 0;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        public NetworkStream(Socket socket, FileAccess access, bool ownsSocket)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket is null");
            }
            if (socket.SocketType != SocketType.Stream)
            {
                throw new ArgumentException("Socket is not of type Stream", "socket");
            }
            if (!socket.Connected)
            {
                throw new IOException("Not connected");
            }
            if (!socket.Blocking)
            {
                throw new IOException("Operation not allowed on a non-blocking socket.");
            }

            this.socket      = socket;
            this.owns_socket = ownsSocket;
            this.access      = access;

            readable  = CanRead;
            writeable = CanWrite;
        }
Ejemplo n.º 3
0
        public NetworkStream(CrestronSocket socket, FileAccess access, bool ownsSocket)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket is null");
            }
            if (!socket.Connected)
            {
                throw new IOException("Not connected");
            }

            this.socket = socket;
            owns_socket = ownsSocket;
            this.access = access;

            readable  = access == FileAccess.ReadWrite || access == FileAccess.Read;
            writeable = access == FileAccess.ReadWrite || access == FileAccess.Write;
        }
Ejemplo n.º 4
0
 public NetworkStream(CrestronSocket socket, FileAccess access)
     : this(socket, access, false)
 {
 }
Ejemplo n.º 5
0
 public NetworkStream(CrestronSocket socket, bool ownsSocket)
     : this(socket, FileAccess.ReadWrite, ownsSocket)
 {
 }
Ejemplo n.º 6
0
 public NetworkStream(CrestronSocket socket)
     : this(socket, FileAccess.ReadWrite, false)
 {
 }