+#include "platform_api.h"
+#include "socket.h"
#include <cerrno>
#include <unistd.h>
#include <fcntl.h>
-#include "platform_api.h"
#include <msp/core/systemerror.h>
#include <msp/io/handle_private.h>
#include <msp/time/rawtime_private.h>
#include "sockaddr_private.h"
-#include "socket.h"
#include "socket_private.h"
+using namespace std;
+
namespace Msp {
namespace Net {
void Socket::Private::set_inherit(bool i)
{
int flags = fcntl(handle, F_GETFD);
- fcntl(handle, F_SETFD, (flags&~O_CLOEXEC)|(i?O_CLOEXEC:0));
+ fcntl(handle, F_SETFD, (flags&~O_CLOEXEC)|(i?0:O_CLOEXEC));
}
int Socket::Private::set_option(int level, int optname, const void *optval, socklen_t optlen)
}
-unsigned check_sys_error(int ret, const char *func)
+size_t check_sys_error(make_signed<size_t>::type ret, const char *func)
{
if(ret<0)
{
- if(errno==EAGAIN)
+ if(errno==EAGAIN || errno==EWOULDBLOCK)
return 0;
else
throw system_error(func);