X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fclientsocket.cpp;h=89e2d082a65bddee2cdfd1f32334f2fb0f3a57bf;hb=3ab65d35cfd696002e09768a38f98e6a2e1ade81;hp=04d07000a7bb1286c105a1697fdc71f0bc880901;hpb=88bbb4039aa274c7f41ebe3a18085b63427e5475;p=libs%2Fnet.git diff --git a/source/net/clientsocket.cpp b/source/net/clientsocket.cpp index 04d0700..89e2d08 100644 --- a/source/net/clientsocket.cpp +++ b/source/net/clientsocket.cpp @@ -7,15 +7,11 @@ 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()) { } @@ -55,12 +51,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 +68,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 +77,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;