]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/clientsocket.h
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / clientsocket.h
index ab8332235cabbaaa5144def7a049214cc9069244..80d927a330c63847c8a9cdfe88643681dad75680 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_NET_CLIENTSOCKET_H_
 #define MSP_NET_CLIENTSOCKET_H_
 
+#include "mspnet_api.h"
 #include "socket.h"
 
 namespace Msp {
@@ -9,16 +10,16 @@ namespace Net {
 /**
 ClientSockets are used for sending and receiving data over the network.
 */
-class ClientSocket: public Socket
+class MSPNET_API ClientSocket: public Socket
 {
 public:
        /** Emitted when the socket finishes connecting. */
        sigc::signal<void, const std::exception *> signal_connect_finished;
 
 protected:
-       bool connecting;
-       bool connected;
-       SockAddr *peer_addr;
+       bool connecting = false;
+       bool connected = false;
+       std::unique_ptr<SockAddr> peer_addr;
 
        ClientSocket(const Private &, const SockAddr &);
        ClientSocket(Family, int, int);
@@ -42,8 +43,8 @@ public:
 
        const SockAddr &get_peer_address() const;
 protected:
-       virtual std::size_t do_write(const char *, std::size_t);
-       virtual std::size_t do_read(char *, std::size_t);
+       std::size_t do_write(const char *, std::size_t) override;
+       std::size_t do_read(char *, std::size_t) override;
 };
 
 } // namespace Net