TCP套接字发送的字节数较少 [英] TCP socket sending less number of bytes

查看:426
本文介绍了TCP套接字发送的字节数较少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用boost.asio库发送大量的字节如下:

I am trying to send a large number of bytes using boost.asio library as following:

void tcp_send(boost::asio::io_service &io, const char *dst_ip, uint16 dst_port)
{
    uint8 *sbuff;
    size_t slen;
    ip::tcp::socket sock(io);

    sock.connect(ip::tcp::endpoint(ip::address::from_string(dst_ip), dst_port));

    sbuff = new uint8[100412];
    sbuff[0] = 67;
    sbuff[1] = 193;
    sbuff[2] = 136;
    sbuff[3] = 60;

    boost::asio::async_write(sock, boost::asio::buffer(sbuff, 100412),
             boost::bind((&send_handler), placeholders::error));
}



当我使用wireshark检查传输的字节数时,发送器总是发送只有65536字节的数据不包括TCP头字节。那么什么可能是问题?
我需要修改任何参数。

When I check the number of transmitted bytes using wireshark, the sender sends always and only 65536 bytes of data excluding TCP header bytes. So what might be the problem? Is there any parameter I need to modify.

我在linux ubuntu上运行应用程序。看来,传输的字节数最多为2 ^ 16。

I am running the application on linux ubuntu. It seems that the maximum number of transmitted bytes is 2^16.

推荐答案

TCP是

成功调用 send 不一定意味着数据已发送;只是TCP栈接受数据并承诺发送它(除非你指定PSH)。

Successfully calling send doesn't necessarily even mean that the data was sent yet; just that the TCP stack accepted the data and promises to send it (unless you specify PSH).

这篇关于TCP套接字发送的字节数较少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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