Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit db1793c

Browse files
authored
Add support for Unix Domain Sockets (#25246)
* Move UnixDomainSocketEndPoint to System.Net.Sockets. * Expose UnixDomainSocketEndPoint publicly in System.Net.Sockets. Fix #10981 * Split UnixDomainSocketTest netcoreapp specific pieces to only be compiled for netcoreapp. Also - fix the new test names to follow the existing format in the file.
1 parent 810746b commit db1793c

File tree

10 files changed

+398
-422
lines changed

10 files changed

+398
-422
lines changed

src/System.IO.Pipes/src/Resources/Strings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@
162162
<data name="ArgumentOutOfRange_MaxNumServerInstances" xml:space="preserve">
163163
<value>maxNumberOfServerInstances must either be a value between 1 and 254, or NamedPipeServerStream.MaxAllowedServerInstances (to obtain the maximum number allowed by system resources).</value>
164164
</data>
165-
<data name="ArgumentOutOfRange_PathLengthInvalid" xml:space="preserve">
166-
<value>The path '{0}' is of an invalid length for use with domain sockets on this platform. The length must be between 1 and {1} characters, inclusive.</value>
167-
</data>
168165
<data name="ArgumentOutOfRange_NeedPosNum" xml:space="preserve">
169166
<value>Positive number required.</value>
170167
</data>

src/System.IO.Pipes/src/System.IO.Pipes.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@
164164
<Compile Include="System\IO\Pipes\NamedPipeClientStream.Unix.cs" />
165165
<Compile Include="System\IO\Pipes\NamedPipeServerStream.Unix.cs" />
166166
<Compile Include="System\IO\Pipes\PipeStream.Unix.cs" />
167-
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
168167
<Compile Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeFileHandleHelper.Unix.cs">
169168
<Link>Common\Microsoft\Win32\SafeHandles\SafeFileHandleHelper.Unix.cs</Link>
170169
</Compile>
@@ -189,9 +188,6 @@
189188
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.FLock.cs">
190189
<Link>Common\Interop\Unix\Interop.FLock.cs</Link>
191190
</Compile>
192-
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetDomainSocketSizes.cs">
193-
<Link>Common\Interop\Unix\Interop.GetDomainSocketSizes.cs</Link>
194-
</Compile>
195191
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetHostName.cs">
196192
<Link>Common\Interop\Unix\Interop.GetHostName.cs</Link>
197193
</Compile>
@@ -264,4 +260,4 @@
264260
<Reference Include="System.Net.Sockets" />
265261
</ItemGroup>
266262
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
267-
</Project>
263+
</Project>

src/System.Net.Sockets/ref/System.Net.Sockets.netcoreapp.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ public partial class SocketAsyncEventArgs : System.EventArgs, System.IDisposable
2929
public System.Memory<byte> GetBuffer() { throw null; }
3030
public void SetBuffer(System.Memory<byte> buffer) { throw null; }
3131
}
32+
33+
public sealed partial class UnixDomainSocketEndPoint : System.Net.EndPoint
34+
{
35+
public UnixDomainSocketEndPoint(string path) { }
36+
}
3237
}

src/System.Net.Sockets/src/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@
220220
<data name="ArgumentOutOfRange_NeedPosNum" xml:space="preserve">
221221
<value>Positive number required.</value>
222222
</data>
223+
<data name="ArgumentOutOfRange_PathLengthInvalid" xml:space="preserve">
224+
<value>The path '{0}' is of an invalid length for use with domain sockets on this platform. The length must be between 1 and {1} characters, inclusive.</value>
225+
</data>
223226
<data name="net_io_readwritefailure" xml:space="preserve">
224227
<value>Unable to transfer data on the transport connection: {0}.</value>
225228
</data>

src/System.Net.Sockets/src/System.Net.Sockets.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<Compile Include="System\Net\Sockets\SocketAsyncEventArgs.Windows.cs" />
144144
<Compile Include="System\Net\Sockets\SocketPal.Windows.cs" />
145145
<Compile Include="System\Net\Sockets\TransmitFileAsyncResult.Windows.cs" />
146+
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Windows.cs" />
146147
<Compile Include="$(CommonPath)\System\Net\SafeCloseSocket.Windows.cs">
147148
<Link>Common\System\Net\SafeCloseSocket.Windows.cs</Link>
148149
</Compile>
@@ -266,6 +267,7 @@
266267
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Unix.cs" />
267268
<Compile Include="System\Net\Sockets\SocketAsyncEventArgs.Unix.cs" />
268269
<Compile Include="System\Net\Sockets\SocketPal.Unix.cs" />
270+
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
269271
<Compile Include="$(CommonPath)\System\Net\ContextAwareResult.Unix.cs">
270272
<Link>Common\System\Net\ContextAwareResult.Unix.cs</Link>
271273
</Compile>
@@ -311,6 +313,9 @@
311313
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetBytesAvailable.cs">
312314
<Link>Interop\Unix\System.Native\Interop.GetBytesAvailable.cs</Link>
313315
</Compile>
316+
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetDomainSocketSizes.cs">
317+
<Link>Common\Interop\Unix\Interop.GetDomainSocketSizes.cs</Link>
318+
</Compile>
314319
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetPeerName.cs">
315320
<Link>Interop\Unix\System.Native\Interop.GetPeerName.cs</Link>
316321
</Compile>
@@ -415,4 +420,4 @@
415420
<Reference Include="System" />
416421
</ItemGroup>
417422
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
418-
</Project>
423+
</Project>

src/System.IO.Pipes/src/System/Net/Sockets/UnixDomainSocketEndPoint.cs renamed to src/System.Net.Sockets/src/System/Net/Sockets/UnixDomainSocketEndPoint.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace System.Net.Sockets
99
{
1010
/// <summary>Represents a Unix Domain Socket endpoint as a path.</summary>
11-
internal sealed class UnixDomainSocketEndPoint : EndPoint
11+
public sealed class UnixDomainSocketEndPoint : EndPoint
1212
{
1313
private const AddressFamily EndPointAddressFamily = AddressFamily.Unix;
1414

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System.Net.Sockets
6+
{
7+
/// <summary>Represents a Unix Domain Socket endpoint as a path.</summary>
8+
public sealed class UnixDomainSocketEndPoint : EndPoint
9+
{
10+
public UnixDomainSocketEndPoint(string path)
11+
{
12+
throw new PlatformNotSupportedException();
13+
}
14+
}
15+
}

src/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<Compile Include="MulticastOptionTest.cs" />
4949
<Compile Include="UdpClientTest.cs" />
5050
<Compile Include="UnixDomainSocketTest.cs" />
51+
<Compile Include="UnixDomainSocketTest.netcoreapp.cs" Condition="'$(TargetGroup)' != 'netstandard'" />
5152
<!-- Common Sockets files -->
5253
<Compile Include="$(CommonTestPath)\System\Net\Configuration.cs">
5354
<Link>SocketCommon\Configuration.cs</Link>

0 commit comments

Comments
 (0)