本文介绍了c套接字编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我不知道"recv"函数中接收缓冲区的大小,该怎么办.当im在while循环中时,接收缓冲区的大小有所不同,但是在"recv"函数中,我必须事先提及大小,这会导致错误的缓冲区.

what if i do not know the size of receive buffer in "recv" function . When i m in a while loop the size of receive buffer differs but in "recv" function i have to mention the size before hand, which gives wrong buffer.

推荐答案


对于面向连接的套接字(例如,类型为SOCK_STREAM),调用recv将返回与当前可用数据一样多的数据-达到指定缓冲区的大小.

For connection-oriented sockets (type SOCK_STREAM for example), calling recv will return as much data as is currently available—up to the size of the buffer specified.




这篇关于c套接字编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 21:17