[w32handle] Remove use of w32handle for File, Console, Pipe and Socket (#5319)
[mono.git] / mcs / class / System / System.Net.Sockets / Socket.cs
index d19756b6c30013be319b87d94a0747081fc47394..ae92b8d730bb51f7ad2493ae02351ccd90cbfb36 100644 (file)
@@ -2265,6 +2265,9 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
 
 #region DuplicateAndClose
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               static extern bool Duplicate_internal(IntPtr handle, int targetProcessId, out IntPtr duplicateHandle, out MonoIOError error);
+
                [MonoLimitation ("We do not support passing sockets across processes, we merely allow this API to pass the socket across AppDomains")]
                public SocketInformation DuplicateAndClose (int targetProcessId)
                {
@@ -2275,9 +2278,8 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
                                (is_blocking       ? 0 : SocketInformationOptions.NonBlocking) |
                                (useOverlappedIO ? SocketInformationOptions.UseOnlyOverlappedIO : 0);
 
-                       MonoIOError error;
                        IntPtr duplicateHandle;
-                       if (!MonoIO.DuplicateHandle (System.Diagnostics.Process.GetCurrentProcess ().Handle, Handle, new IntPtr (targetProcessId), out duplicateHandle, 0, 0, 0x00000002 /* DUPLICATE_SAME_ACCESS */, out error))
+                       if (!Duplicate_internal (Handle, targetProcessId, out duplicateHandle, out MonoIOError error))
                                throw MonoIO.GetException (error);
 
                        si.ProtocolInformation = Mono.DataConverter.Pack ("iiiil", (int)addressFamily, (int)socketType, (int)protocolType, is_bound ? 1 : 0, (long)duplicateHandle);