X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fclientsocket.cpp;h=fbbd2415c693911b88063f0091600d0d3e73f25a;hb=cc2e643d6ec3025db3fb6f0a4c1f77af05cf1026;hp=04d07000a7bb1286c105a1697fdc71f0bc880901;hpb=88bbb4039aa274c7f41ebe3a18085b63427e5475;p=libs%2Fnet.git diff --git a/source/net/clientsocket.cpp b/source/net/clientsocket.cpp index 04d0700..fbbd241 100644 --- a/source/net/clientsocket.cpp +++ b/source/net/clientsocket.cpp @@ -1,21 +1,17 @@ #include "platform_api.h" -#include #include "clientsocket.h" +#include #include "socket_private.h" 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()) { } @@ -23,8 +19,6 @@ ClientSocket::ClientSocket(const Private &p, const SockAddr &paddr): ClientSocket::~ClientSocket() { signal_flush_required.emit(); - - delete peer_addr; } void ClientSocket::shutdown(IO::Mode m) @@ -55,12 +49,12 @@ 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; } -unsigned ClientSocket::do_write(const char *buf, unsigned size) +size_t ClientSocket::do_write(const char *buf, size_t size) { check_access(IO::M_WRITE); if(!connected) @@ -72,7 +66,7 @@ unsigned ClientSocket::do_write(const char *buf, unsigned size) return check_sys_error(::send(priv->handle, buf, size, 0), "send"); } -unsigned ClientSocket::do_read(char *buf, unsigned size) +size_t ClientSocket::do_read(char *buf, size_t size) { check_access(IO::M_READ); if(!connected) @@ -81,12 +75,12 @@ unsigned ClientSocket::do_read(char *buf, unsigned size) if(size==0) return 0; - unsigned ret = check_sys_error(::recv(priv->handle, buf, size, 0), "recv"); + size_t 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_socket_events(S_NONE); + signal_end_of_file.emit(); } return ret;