- MySocket* mysocket = get_my_socket(localSocket);
- if (mysocket->remaining == 0){
- //all data was already buffered (and socket was already closed), just return
- return;
- }
- while (mysocket->sentBytes < mysocket->totalBytes
- && localSocket->GetTxAvailable () > 0)
- {
- uint32_t toWrite = min ((mysocket->remaining), txSpace);
- toWrite = min (toWrite, localSocket->GetTxAvailable ());
- int amountSent = localSocket->Send (data, toWrite, 0);
+
+ while (flow->bufferedBytes_ < flow->totalBytes_ && sock->GetTxAvailable () > 0) {
+
+ uint32_t toWrite = std::min ({flow->remaining_, txSpace, sock->GetTxAvailable ()});
+ int amountSent = sock->Send (data, toWrite, 0);