TcpClient.GetStream (). Read () vs TcpClient.Client.Receive ()

.NET allows two very similar ways to "read" from the network (assuming TCP is connected):

1. TcpClient.GetStream().Read() 
2. TcpClient.Client.Receive()

After examining the source code for NetworkStream, it seems like it's an extra shell over the underlying socket, which ultimately calls Socket methods.

Question: What is the use of using the “indirect” variation of NetworkStream (# 1) instead of using the direct shell provided by the Socket implementation?

Thank you Boris.

+5
source share
3 answers

, , (TcpStream, Socket). , API , .

, , SSL , SslStream TcpStream . , Socket API.

+10

, . , Stream.

+1

Socket.Receive , .

-1

All Articles