Не могу запустить небольшой сервер клиентского прог
Hello With very low knowledege in server Client program and in server client program which was posted in codeproject <a href="https://www.codeproject.com/Articles/1415/Introduction-to-TCP-client-server-in-C"></a> i could not run this program ,look at those notes 1 - Both programs are run in same machine(64 bit),.NET FrameWork 4.5 window 10 2- I have got the address from my computer using Ms Dos command=ipconfig/all from Ethernet adapter vEthernet (Default Switch) the IPv4 address = 172.31.57.17 i have made minor change to the program that listed in the above link 3 - to make my question clear using CONTROL PANEL in NETWORK CONNECTION ,i noticed that i have 4 icons one for Ethernet,one for vEthernet(Default Swith) ,one for vEthernet (default switch)2 and last one for wirless after running the program Client i have got his message (No connection could be made because the target machine actively refused it 172.31.57.17:8001) need help What I have tried: <pre lang=" /////Server /////////////////////////////// public partial class Form1 : Form { IPAddress ipAd; TcpListener myList; public Form1() { InitializeComponent(); } private void FormLoad(object sender, EventArgs e) { //ipAd = IPAddress.Parse("172.21.5.99");// as written see the link ipAd = IPAddress.Parse("172.31.57.17");//i have tried this //ipAd = IPAddress.Parse("172.31.57.18");// and this myList = new TcpListener(ipAd, 8001); } private void StartServerClick(object sender, EventArgs e) { myList.Start(); Console.WriteLine("The server is running at port 8001..."); Console.WriteLine("The local End point is :" + myList.LocalEndpoint); Console.WriteLine("Waiting for a connection....."); Socket s = myList.AcceptSocket(); Console.WriteLine("Connection accepted from " + s.RemoteEndPoint); byte[] b = new byte[100]; int k = s.Receive(b); Console.WriteLine("Recieved..."); for (int i = 0; i < k; i++) Console.Write(Convert.ToChar(b[i])); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("The string was recieved by the server.")); Console.WriteLine("\nSent Acknowledgement"); s.Close(); myList.Stop(); } } ///////////////////////////Client ////////////////////////////////////////////////// TcpClient tcpclnt; public Form1() { InitializeComponent(); } private void FormLoad(object sender, EventArgs e) { tcpclnt = new TcpClient(); } private void StartClient(object sender, EventArgs e) { Console.WriteLine("Connecting....."); tcpclnt.Connect("172.31.57.17", 8001); // use the ipaddress as in the server program //tcpclnt.Connect("172.31.57.18", 8001); Console.WriteLine("Connected"); Console.Write("Enter the string to be transmitted : "); String str=Console.ReadLine(); Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen= new ASCIIEncoding(); byte[] ba=asen.GetBytes(str); Console.WriteLine("Transmitting....."); stm.Write(ba,0,ba.Length); byte[] bb=new byte[100]; int k=stm.Read(bb,0,100); for (int i=0;i<k;i++) Console.Write(Convert.ToChar(bb[i])); tcpclnt.Close(); } } ">
Engineer khalid
я попытался подключить один компьютер(окно 7) и другой компьютер, используя окно 10 в Wireless net, и я написал ip-адрес в обоих компьютерах
(тот же адрес) ,все еще не работает
затем я подключаю оба компьютера с помощью кабеля cat6 и lan net все еще не работает