X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fnet%2Fclientsocket.cpp;h=04d07000a7bb1286c105a1697fdc71f0bc880901;hb=88bbb4039aa274c7f41ebe3a18085b63427e5475;hp=d28d0e90b930487b4a573cb751356baf10575666;hpb=30f362b6a1257aa0a01a926de8b774fe90d4be39;p=libs%2Fnet.git diff --git a/source/net/clientsocket.cpp b/source/net/clientsocket.cpp index d28d0e9..04d0700 100644 --- a/source/net/clientsocket.cpp +++ b/source/net/clientsocket.cpp @@ -1,9 +1,4 @@ -#ifdef WIN32 -#include -#else -#include -#include -#endif +#include "platform_api.h" #include #include "clientsocket.h" #include "socket_private.h" @@ -36,7 +31,7 @@ void ClientSocket::shutdown(IO::Mode m) { int how; m = m&IO::M_RDWR; -#ifdef WIN32 +#ifdef _WIN32 if(m==IO::M_READ) how = SD_RECEIVE; else if(m==IO::M_WRITE) @@ -74,16 +69,7 @@ unsigned ClientSocket::do_write(const char *buf, unsigned size) if(size==0) return 0; - int ret = ::send(priv->handle, buf, size, 0); - if(ret<0) - { - if(errno==EAGAIN) - return 0; - else - throw system_error("send"); - } - - return ret; + return check_sys_error(::send(priv->handle, buf, size, 0), "send"); } unsigned ClientSocket::do_read(char *buf, unsigned size) @@ -95,19 +81,12 @@ unsigned ClientSocket::do_read(char *buf, unsigned size) if(size==0) return 0; - int ret = ::recv(priv->handle, buf, size, 0); - if(ret<0) - { - if(errno==EAGAIN) - return 0; - else - throw system_error("recv"); - } - else if(ret==0 && !eof_flag) + unsigned ret = check_sys_error(::recv(priv->handle, buf, size, 0), "recv"); + if(ret==0 && !eof_flag) { eof_flag = true; signal_end_of_file.emit(); - set_events(IO::P_NONE); + set_socket_events(S_NONE); } return ret;