Przeglądaj źródła

Close socket when dtor called

Daniele Bartolini 12 lat temu
rodzic
commit
a4d8f404e6
2 zmienionych plików z 18 dodań i 0 usunięć
  1. 12 0
      engine/os/posix/OsSocket.h
  2. 6 0
      engine/os/win/OsSocket.h

+ 12 - 0
engine/os/posix/OsSocket.h

@@ -68,6 +68,12 @@ public:
 	{
 	}
 
+	//-----------------------------------------------------------------------------
+	~TCPSocket()
+	{
+		close();
+	}
+
 	//-----------------------------------------------------------------------------
 	bool open(const NetAddress& destination, uint16_t port)
 	{
@@ -167,6 +173,12 @@ class TCPListener
 {
 public:
 
+	//-----------------------------------------------------------------------------
+	~TCPListener()
+	{
+		close();
+	}
+
 	//-----------------------------------------------------------------------------
 	bool open(uint16_t port)
 	{

+ 6 - 0
engine/os/win/OsSocket.h

@@ -173,6 +173,12 @@ class TCPListener
 {
 public:
 
+	//-----------------------------------------------------------------------------
+	~TCPListener()
+	{
+		close();
+	}
+
 	//-----------------------------------------------------------------------------
 	bool open(uint16_t port)
 	{