有没有办法调用 send/recv 传递向量?
在 C++ 中缓冲套接字数据的好习惯是什么?例如:读取直到 \r\n 或直到 upper_bound ( 4096 字节)
std::vector<char> b(100);
send(z,&b[0],b.size(),0);
Edit: 我第二本·海姆斯的 https://stackoverflow.com/questions/1399891/c-vectorchar-and-sockets/1400077#1400077 and me22's https://stackoverflow.com/questions/1399891/c-vectorchar-and-sockets/1400289#1400289评论。另请参阅这个答案 https://stackoverflow.com/questions/1339470/how-to-get-the-address-of-the-stdvector-buffer-start-most-elegantly/1339767#1339767对于不尝试访问空向量中的第一个元素的通用实现。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)