[Socket] Fix DuplicateAndClose (#3995)
authorKenneth Skovhede <kenneth@hexad.dk>
Wed, 23 Nov 2016 00:04:57 +0000 (01:04 +0100)
committerLudovic Henry <ludovic@xamarin.com>
Wed, 23 Nov 2016 00:04:57 +0000 (19:04 -0500)
commit1e6c680fa2f18ef42bd488cd373309a7a4012846
tree71a96e1b1ff7a9a1083dbf1b2b16ac836db44fe7
parentc2e2d0dbfddbd8c22c6eeec0933c65bd0b9ca891
[Socket] Fix DuplicateAndClose (#3995)

* Fixed issue 47425

This fix simply ensures that the `m_Handle` value is not processed by the GC after a call to `DuplicateAndClose` as that causes the duplicated socket to close.

A potential issue is that this will leak sockets if the sockets are never re-created.

* Implemented ref-counting as suggested by @ludovic-henry
mcs/class/System/System.Net.Sockets/Socket.cs