C#网络编程中面向连接的套接字编程
各位大虾好:本人刚刚学习网络编程,对面向连接的套接字编程不是很懂,现请教各位大虾:怎么编程一个简单的面向套接字的程序,要在执行时,显示框自动关闭就表示,连接成功。
IPHostEntry local = Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint iep = new IPEndPoint(local.AddressList[0],8000);
Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
mySocket.Bind(iep);
mySocket.Listen(10);
Socket myClient = mySocket.Accept();
IPAddress remoteHost = IPAddress.Parse("192.168.0.1");
IPEndPoint iep1 = new IPEndPoint(remoteHost, 8000);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Connect(iep1);