C++/socket缓冲区的大小设置

//设置socket发送、接收缓冲区大小为64k,默认为8k,最大为64k
int value=65535;
int tmpCode=0;
tmpCode=::setsockopt(m_UdpSendSocket_Quot, SOL_SOCKET, SO_RCVBUF, (char*)&value, sizeof(value));
tmpCode=::setsockopt(m_UdpSendSocket_Quot, SOL_SOCKET, SO_SNDBUF, (char*)&value, sizeof(value));
int result=0;
int len=4;
tmpCode=::getsockopt((SOCKET)m_UdpSendSocket_Quot,SOL_SOCKET, SO_RCVBUF, (char*)&result, &len);
printf("SO_RCVBUF=%d, tmpCode=%d\n", result,tmpCode);
tmpCode=::getsockopt((SOCKET)m_UdpSendSocket_Quot,SOL_SOCKET, SO_SNDBUF, (char*)&result, &len);
printf("SO_SNDBUF=%d, tmpCode=%d\n", result,tmpCode);
发布了57 篇原创文章 · 获赞 35 · 访问量 67万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览