-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Every time you retrieve the Socket.LocalEndPoint property, we do a kernel call to retrieve the local end point. Since this cannot change once the socket is open, we should cache this, as we do for RemoteEndPoint.
(Or alternatively, we can get the endpoint directly from the result of the AcceptEx call, as we do for RemoteEndPoint. However, this may introduce some additional overhead in cases where LocalEndPoint is never accessed, so it's not clear this is the right tradeoff in all cases.)
Retrieving the LocalEndPoint is not a common thing to do, so I don't think this issue is particularly urgent, but we should track it.
(I hit this when doing the Kestrel-on-Sockets prototype -- for some reason Kestrel does seem to repeatedly retrieve the LocalEndPoint, and expects it to be cheap, which is not an unreasonable expectation. I worked around the issue by just caching the LocalEndPoint myself.)