Socket.LocalEndPoint is updated after calling SendToAsync
Socket.SendToAsync(SocketAsyncEventArgs) now updates the value of the Socket.LocalEndPoint property to the socket's local address.
Version introduced
5.0
Change description
In previous .NET versions, Socket.SendToAsync(SocketAsyncEventArgs) does not alter the value of the Socket.LocalEndPoint property on the socket instance. Starting in .NET 5, when SendToAsync(SocketAsyncEventArgs) successfully completes, the value of Socket.LocalEndPoint is the implicitly bound socket's local address. This new behavior is consistent with the behavior of SendTo(Byte[], EndPoint) and BeginSendTo(Byte[], Int32, Int32, SocketFlags, EndPoint, AsyncCallback, Object)/EndSendTo(IAsyncResult).
Reason for change
This change fixes a bug and makes the behavior consistent across SendTo
variants.
Recommended action
Alter any code that assumes that SendToAsync(SocketAsyncEventArgs) won't alter the value of Socket.LocalEndPoint.
Affected APIs
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for