打开命名空间using System.Net;using System.Net.Sockets;服务端代码: 1 static void Main(string[] args) 2 { 3 int port = 2000; 4 string host = "127.0.0.1"; 5 6 IPAddress ip = IPAddress.Parse(host); 7 IPEndPoint ipe = new IPEndPoint(ip, port); 8 9 ... Read More
1 IPHostEntry iphost = Dns.GetHostEntry("www.google.com.hk");2 IPAddress[] ip = iphost.AddressList; //获取列表3 EndPoint ep = new IPEndPoint(ip[0], 80); //创建结点4 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //初始化socket5 socket.Connect(ep); //连接6 i Read More