Monday 20 February 2012

fetch ip address in c#

Socket lsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

 change second param to port number you are going to use

IPEndPoint lep = new IPEndPoint(IPAddress.Any, 21);
lsock.Bind(lep);
lsock.Listen(10);
Socket rsock = lsock.Accept();
Console.WriteLine(Remote IP {0},
((IPEndPoint)rsock.RemoteEndPoint).Address.ToStrin g());

No comments:

Post a Comment