]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/clientsocket.cpp
Use nullptr instead of 0 for pointers
[libs/net.git] / source / net / clientsocket.cpp
index 04d07000a7bb1286c105a1697fdc71f0bc880901..89e2d082a65bddee2cdfd1f32334f2fb0f3a57bf 100644 (file)
@@ -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;