NetworkStream和TcpClient有多少缓冲区? [英] How much buffer does NetworkStream and TcpClient have?

查看:222
本文介绍了NetworkStream和TcpClient有多少缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在编写一个TCPServer和Client程序。 TcpClient缓冲区中有多少空间?例如,它将在什么时候开始丢弃数据?我们正在尝试确定TcpClient是否可以阻塞或是否应该进入它自己的后台线程(以便缓冲区无法装满)。

We are writing a TCPServer and Client program. How much space is there in the TcpClient buffer? Like, at what point will it begin to throw away data? We are trying to determine if the TcpClient can be blocking or if it should go into it's own background thread(so that the buffer can not get full)..

推荐答案

您可以从 TcpClient.ReceiveBufferSize TcpClient.SendBufferSize

可用缓冲区的大小会随着接收/确认数据而变化(或不)在TCP级别。

The available buffer sizes will vary as data is received/acknowledged(or not) at the TCP level. TcpClient is blocking by default.

没有数据会由于缓冲区已满而被丢弃,尽管在错误情况下数据也可能被丢弃(例如对等项消失) /崩溃/退出等)

No data will be thrown away as a result of full buffers, though data could be throw away in under error conditions (such as the peer disappears/crashes/exits etc.)

这篇关于NetworkStream和TcpClient有多少缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆