#include "platform_api.h"
-#include <msp/core/systemerror.h>
#include "clientsocket.h"
+#include <msp/core/systemerror.h>
#include "socket_private.h"
+using namespace std;
+
namespace Msp {
namespace Net {
ClientSocket::ClientSocket(Family af, int type, int proto):
- Socket(af, type, proto),
- connecting(false),
- connected(false),
- peer_addr(0)
+ Socket(af, type, proto)
{ }
ClientSocket::ClientSocket(const Private &p, const SockAddr &paddr):
Socket(p),
- connecting(false),
connected(true),
peer_addr(paddr.copy())
{ }
ClientSocket::~ClientSocket()
{
signal_flush_required.emit();
-
- delete peer_addr;
}
void ClientSocket::shutdown(IO::Mode m)
const SockAddr &ClientSocket::get_peer_address() const
{
- if(peer_addr==0)
+ if(!peer_addr)
throw bad_socket_state("not connected");
return *peer_addr;
}
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;
- signal_end_of_file.emit();
- set_socket_events(S_NONE);
+ if(!eof_flag)
+ {
+ set_socket_events(S_NONE);
+ set_eof();
+ }
+ return 0;
}
- return ret;
+ return check_sys_error(ret, "recv");
}
} // namespace Net