puzzlecracker said:
It looks like i need to get IPEndPoint first, but I cannot figure out
from msdn the eventual obtainment of machine name and port number.
Please suggest a solution.
There is no solution. You should be the one responsible for creating
the TcpClient, so you also know the endpoint. Conversely, if you're
just using a TcpClient created somewhere else, you have no business
with the endpoint the TcpClient is abstracting over.
Alright, so there is one solution: use reflection to read the
TcpClient's private members, in particular the Socket it encapsulates.
There is no reason why such code shouldn't break with the next release
of the framework, though. Only use it for an incident. [...]