打开命名空间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
posted @ 2011-11-22 15:46 陈帆 Views(1254) Comments(0) Diggs(2) Edit
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
posted @ 2011-11-22 14:55 陈帆 Views(275) Comments(0) Diggs(0) Edit