Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

c# - What is IP address '::1'?

I was playing with sockets on local machine with no network connection. See below:

IPAddress address = IPAddress.Any; // doesn't work
IPAddress address = IPAddress.Parse("::1"); // works

So what is exactly ::1 IP address ? Is it the default available IP address or it's the loopback address ? what happens to above code (working line) on a machine with dedicated IP address and network connection ?

EDIT:

exact code is used to bind a specific IP address to socket. Here it is:

ServicePoint sp = ServicePointManager.FindServicePoint(uri);
sp.BindIPEndPointDelegate = new BindIPEndPoint(Bind);
// here's the bind delegate:
private IPEndPoint Bind(ServicePoint sp, IPEndPoint ep, int retryCount)
{
   return new IPEndPoint(IPAddress.Parse("::1"), 0);
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

::1 is the loopback address in IPv6. Think of it as the IPv6 version of 127.0.0.1.

See http://en.wikipedia.org/wiki/Localhost


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...