using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; public static class TcpClientExtensions { /// /// Returns the TcpClient remote end point IP address. /// /// The socket. /// public static IPAddress GetIPAddress(this TcpClient socket) { return (socket.Client.RemoteEndPoint as IPEndPoint).Address; } }