我需要跨连接套接字传输缓冲区内容的帮助. [英] I need help with tranmitting content of buffer across connected socket.

查看:68
本文介绍了我需要跨连接套接字传输缓冲区内容的帮助.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用send函数发送缓冲区的内容,并使用recv函数接收,但是我发现没有发送整个缓冲区的内容/没有接收到整个缓冲区的内容.

I tried sending the content of a buffer with send function and receive with recv function but I found out that the entire buffer content was not transmitted/the entire buffer content was not received. What can be the reason and how do I rectify this?

推荐答案

原因可能是您尚未检查这两个函数的文档,您可能不要检查其返回值: send() [ ^ ], recv () [ ^ ].始终检查返回值是否有错误,并且永远不要假定它们发送了整个缓冲区.如果它们仅发送/接收部分数据,则将指针增加到缓冲区中,并发出另一个send()recv()调用以发送/接收其余数据.
The reason can be that you haven''t checked out the documentation of these two functions and you probably don''t check their return value: send()[^], recv()[^]. Always check the return value for errors, and never assume that they sent the whole buffer. If they sent/received only part of the data then increase the pointer into your buffer and issue another send() or recv() call to send/receive the remaining data.


这篇关于我需要跨连接套接字传输缓冲区内容的帮助.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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