-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[SocketException]: New Constructor with string? for SocketException #74744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
liveans
merged 8 commits into
dotnet:main
from
liveans:api-implementation/add-constructor-socket-exception-69266
Sep 7, 2022
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae4530c
API: Constructor with string? for SocketException
liveans 86a7f92
Update: Review changes
liveans 523ad8a
Update: ExtendedSocketException deleted, added few tests
liveans 6194440
Update: Moving files from Internals to Sockets section in Common
liveans c0bd4ba
Update: Review changes
liveans 21edab2
Update: A little fix
liveans 3617875
Update: Move test into async section
liveans 2e4924e
Update: Review changes
liveans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update: Moving files from Internals to Sockets section in Common
- Loading branch information
commit 6194440c85b9ffd58985c97dcf4ecb2d947823bc
There are no files selected for viewing
15 changes: 0 additions & 15 deletions
15
src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.Unix.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.Windows.cs
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/libraries/Common/src/System/Net/Sockets/SocketExceptionFactory.Unix.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace System.Net.Sockets | ||
| { | ||
| internal static partial class SocketExceptionFactory | ||
| { | ||
| public static SocketException CreateSocketException(int socketError, EndPoint? endPoint) | ||
| { | ||
| int nativeErr = (int)socketError; | ||
|
|
||
| // If an interop error was not found, then don't invoke Info().RawErrno as that will fail with assert. | ||
| if (SocketErrorPal.TryGetNativeErrorForSocketError(error, out Interop.Error interopErr)) | ||
| { | ||
| nativeErr = interopErr.Info().RawErrno; | ||
| } | ||
|
|
||
| return new SocketException(socketError, CreateMessage(nativeErr, endPoint)); | ||
| } | ||
| } | ||
| } | ||
7 changes: 3 additions & 4 deletions
7
...m/Net/Internals/SocketExceptionFactory.cs → ...Sockets/SocketExceptionFactory.Windows.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Net.Sockets; | ||
|
|
||
| namespace System.Net.Internals | ||
| namespace System.Net.Sockets | ||
| { | ||
| internal static partial class SocketExceptionFactory | ||
| { | ||
| public static SocketException CreateSocketException(int socketError, EndPoint? endPoint) | ||
| { | ||
| return new SocketException(socketError, endPoint?.ToString()); | ||
| // Windows directly maps socketError to native error code. | ||
| return new SocketException(socketError, CreateMessage(socketError, endPoint)); | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/libraries/Common/src/System/Net/Sockets/SocketExceptionFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace System.Net.Sockets | ||
| { | ||
| internal static partial class SocketExceptionFactory | ||
| { | ||
| private static string CreateMessage(int nativeSocketError, EndPoint? endPoint) | ||
| { | ||
| string message = Marshal.GetPInvokeErrorMessage(nativeSocketError); | ||
| return endPoint == null ? message : message + " " + endPoint.ToString(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.