System.Net.Sockets.TcpClient.GetStream C# (CSharp) Method

GetStream() public method

public GetStream ( ) : NetworkStream
return NetworkStream
        public NetworkStream GetStream()
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(this);

            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (!Connected)
            {
                throw new InvalidOperationException(SR.net_notconnected);
            }

            if (_dataStream == null)
            {
                _dataStream = new NetworkStream(Client, true);
            }

            if (NetEventSource.IsEnabled) NetEventSource.Exit(this, _dataStream);
            return _dataStream;
        }

Usage Example

示例#1
1
文件: Player.cs 项目: roy12345/uMiner
        public Player(TcpClient client, string ip, byte id)
        {
            try
            {
                this.username = "player";
                this.plyClient = client;
                this.x = 0;
                this.y = 0;
                this.z = 0;
                this.rotx = 0;
                this.roty = 0;
                this.prefix = "";
                this.id = id;
                this.ip = ip;

                this.world = null;

                this.outQueue = new Queue<Packet>();
                this.blockQueue = new Queue<Packet>();
                this.IOThread = new Thread(PlayerIO);
                this.outputWriter = new BinaryWriter(client.GetStream());
                this.inputReader = new BinaryReader(client.GetStream());

                this.IOThread.IsBackground = true;
                this.IOThread.Start();
            }
            catch
            {
            }
        }
All Usage Examples Of System.Net.Sockets.TcpClient::GetStream