ithewei / libhv

🔥 比libevent/libuv/asio更易用的网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket/MQTT client/server.

Home Page:https://github.com/ithewei/libhv/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected delimiter

Flyingbeanss opened this issue · comments

Hi , I just found this repo and I'm interested with it.
I'm trying to send and recive files with TCP.
I coded based on examples.But I got some problems, the file I receive had unexpected delimiter, just like two tabs with a 'c'. I'm sure I didn't set the unpack setting.
The server just send file every 4096B and the client receive file every 4096B. Can someone help me? Thanks!

std::string data(fileContent.begin(),fileContent.end());
int datalen=data.length()
socket.broadcast(std::to_string(datalen)+"/////");
for(int i=0;i<datalen;i+=4096)
{
    std::string tmpstr=data.substr(i,4096);
    socket.broadcast(tmpstr);
}