blob: f560b5a23005f8695ce11613ece7148d34f07fbd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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
{
/// <summary>
/// Returns the TcpClient remote end point IP address.
/// </summary>
/// <param name="socket">The socket.</param>
/// <returns></returns>
public static IPAddress GetIPAddress(this TcpClient socket)
{
return (socket.Client.RemoteEndPoint as IPEndPoint).Address;
}
}
|