#include <msp/core/systemerror.h>
#include "socket_private.h"
+using namespace std;
+
namespace Msp {
namespace Net {
if(size==0)
return 0;
- size_t ret = check_sys_error(::recv(priv->handle, buf, size, 0), "recv");
- if(ret==0 && !eof_flag)
+ make_signed<size_t>::type ret = ::recv(priv->handle, buf, size, 0);
+ if(ret==0)
{
- eof_flag = true;
- set_socket_events(S_NONE);
- signal_end_of_file.emit();
+ if(!eof_flag)
+ {
+ set_socket_events(S_NONE);
+ set_eof();
+ }
+ return 0;
}
- return ret;
+ return check_sys_error(ret, "recv");
}
} // namespace Net