NetworkStream doesn't support seek operations

前端 未结 4 514
鱼传尺愫
鱼传尺愫 2021-01-24 02:21

I\'m creating simple proxy server but I faced a strange situation, I\'ve following code :

var clientRequestStream = _tcpClient.GetStream();
var requestHeader = c         


        
4条回答
  •  悲哀的现实
    2021-01-24 02:54

    You won't be able to set clientRequestStream.Position = 0 because NetworkStream is forward-only. See here: http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.position.aspx

    Be careful about thinking of NetworkStream in the same way as regular streams. Things like Peek() for example on a StreamReader can cause your application to block.

提交回复
热议问题