TcpListener.LocalEndPoint property should really be IPEndPoint, not EndPoint #63117
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Net.Sockets
Milestone
Since TcpListener is specific to TCP, the LocalEndPoint is always an IPEndPoint, yet it's typed as EndPoint. This means users of this property need to downcast to IPEndPoint to access the actual IPAddress and Port.
We should consider adding new API here so that it's obvious that this can only be an IPEndPoint, and users don't have to do the downcast themselves.
We could simply add a new property like "LocalIPEndPoint", or perhaps "ListenEndPoint" -- I like the latter personally, it calls out that this is different than the typical Local/RemoteEndPoint semantics for connected sockets.
Or we could choose to avoid EndPoint/IPEndPoint entirely and expose the IPAddress and Port as separate properties, something like "ListenIPAddress" and "ListenPort".
The text was updated successfully, but these errors were encountered: