📜  c# 套接字绑定到 localhost - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:43.355000             🧑  作者: Mango

代码示例1
IPAddress address = Dns.GetHostAddresses("localhost").Where(x => x.AddressFamily == AddressFamily.InterNetwork).First();
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(new IPEndPoint(address, port));