Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LanguageMachines/ticcutils
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed May 16, 2018
2 parents ba02888 + d77baaa commit bebdeb6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/SocketBasics.cxx
Expand Up @@ -86,6 +86,8 @@ namespace Sockets {
cerr << "read res = " << bytes_read << " ( " << strerror(bytes_read) << ")" << endl;
#endif
// The other side may have closed unexpectedly
::close(sock);
sock = -1;
break;
}
if ( ( last_read != 10 ) && ( last_read !=13 ) ) {
Expand Down Expand Up @@ -149,6 +151,8 @@ namespace Sockets {
}
else {
mess = strerror( res );
::close(sock);
sock = -1;
return false;
}
}
Expand All @@ -175,14 +179,17 @@ namespace Sockets {
cerr << "write res = " << this_write << " ( " << strerror(this_write) << ")" << endl;
#endif
} while ( (this_write < 0) && (errno == EINTR) );
if (this_write <= 0)
if (this_write <= 0){
break;
}
bytes_sent += this_write;
str += this_write;
}
if ( bytes_sent < count ) {
mess = "write: failed to sent " + TiCC::toString(count - bytes_sent) +
" bytes out of " + TiCC::toString(count);
::close(sock);
sock = -1;
return false;
}
}
Expand Down Expand Up @@ -213,12 +220,16 @@ namespace Sockets {
}
else {
mess = strerror( res );
::close(sock);
sock = -1;
return false;
}
}
if ( bytes_sent < count ) {
mess = "write: failed to sent " + TiCC::toString(count - bytes_sent) +
" bytes out of " + TiCC::toString(count);
::close(sock);
sock = -1;
return false;
}
}
Expand Down

0 comments on commit bebdeb6

Please sign in to comment.