#include "platform_api.h"
+#include "socket.h"
#include <msp/core/systemerror.h>
#include <msp/io/handle_private.h>
#include "sockaddr_private.h"
-#include "socket.h"
#include "socket_private.h"
using namespace std;
namespace Net {
Socket::Socket(const Private &p):
- priv(new Private)
+ priv(make_unique<Private>())
{
mode = IO::M_RDWR;
SockAddr::SysAddr sa;
getsockname(priv->handle, reinterpret_cast<sockaddr *>(&sa.addr), &sa.size);
- local_addr = SockAddr::new_from_sys(sa);
+ local_addr.reset(SockAddr::new_from_sys(sa));
platform_init();
}
Socket::Socket(Family af, int type, int proto):
- priv(new Private)
+ priv(make_unique<Private>())
{
mode = IO::M_RDWR;
Socket::~Socket()
{
platform_cleanup();
-
- delete local_addr;
- delete priv;
}
void Socket::set_block(bool b)
if(err==-1)
throw system_error("bind");
- delete local_addr;
- local_addr = addr.copy();
+ local_addr.reset(addr.copy());
}
const SockAddr &Socket::get_local_address() const