From 9e28495cb7309ea07431a02838eccbbb46841daa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 9 Jun 2018 19:18:41 +0200 Subject: Fix send not working, allow sending 0 bytes --- src/DirectConnection.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/DirectConnection.cpp') diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp index 713b3ac..8e60c47 100644 --- a/src/DirectConnection.cpp +++ b/src/DirectConnection.cpp @@ -126,7 +126,7 @@ namespace sibs std::thread([peer, data, sendDataCallbackFunc]() { usize sentSizeTotal = 0; - while(sentSizeTotal < data->size()) + while(sentSizeTotal < data->size() || data->size() == 0) { int sentSize = UDT::send(peer->socket, (char*)data->data() + sentSizeTotal, data->size() - sentSizeTotal, 0); if(sentSize == UDT::ERROR) @@ -135,6 +135,8 @@ namespace sibs sendDataCallbackFunc(PubSubResult::ERROR, UDT::getlasterror_desc()); } sentSizeTotal += sentSize; + if(data->size() == 0) + break; } if(sendDataCallbackFunc) sendDataCallbackFunc(PubSubResult::OK, ""); -- cgit v1.2.3