diff C++/Socket.cpp @ 280:91eb0583df52

Socket: * Fix select method that require fdset's to be rebuild at each iteration, * While here always create a m_interface Task: #306
author David Demelier <markand@malikania.fr>
date Fri, 24 Oct 2014 18:28:39 +0200
parents 05f0a3e09cbf
children ea55a3886da0
line wrap: on
line diff
--- a/C++/Socket.cpp	Fri Oct 24 10:28:17 2014 +0200
+++ b/C++/Socket.cpp	Fri Oct 24 18:28:39 2014 +0200
@@ -202,7 +202,7 @@
 	// Usually accept works only with SOCK_STREAM
 	info = SocketAddress(address, addrlen);
 
-	return Socket(handle);
+	return Socket(handle, std::make_shared<Standard>());
 }
 
 void Standard::listen(Socket &s, int max)
@@ -316,8 +316,13 @@
  * Socket code
  * -------------------------------------------------------- */
 
+Socket::Socket()
+	: m_interface(std::make_shared<Standard>())
+{
+}
+
 Socket::Socket(int domain, int type, int protocol)
-	: m_interface(std::make_unique<Standard>())
+	: Socket()
 {
 	m_handle = socket(domain, type, protocol);
 
@@ -325,8 +330,8 @@
 		throw error::Failure("socket", syserror());
 }
 
-Socket::Socket(Handle handle)
-	: m_interface(std::make_shared<Standard>())
+Socket::Socket(Handle handle, std::shared_ptr<SocketInterface> interface)
+	: m_interface(std::move(interface))
 	, m_handle(handle)
 {
 }