Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

private void startsrv_Click(object sender, EventArgs e)
        {
            server.Start();
            Thread checkforip = new Thread(new ThreadStart(CheckForIPs));
            checkforip.Start();
            MessageBox.Show("Server nu1 started");
        }

        private void onlylistentobtn_Click(object sender, EventArgs e)
        {
            
            server2 = new TcpListener(IPAddress.Parse(onlytotxtbox.Text), 9998);
            server2.Start();
            TcpClient conn2 = server2.AcceptTcpClient();
            StreamWriter sw = new StreamWriter(conn2.GetStream());
            sw.WriteLine("1");
            sw.Flush();
            MessageBox.Show("Server nu2 started");
        }


Now when I debug it it stops at server2.Start(), exception: SocketException:The requested address is not valid in its context

What I can't understand is that the server.Start() starts server1, and I don't know why the second one doesn't.

Any ideas?
Posted
Comments
HimanshuJoshi 1-Oct-10 14:58pm    
What IP address are you entering?
velvet7 1-Oct-10 15:06pm    
192.168.1.4 (which is my brothers lan address)
velvet7 1-Oct-10 16:15pm    
So, I tried it on my friends computer, and it also connects there to server, but it doesn't connect to server2. With the same exception.
HimanshuJoshi 1-Oct-10 17:58pm    
You need to supply the IP address of computer on which you are running the progranm. Or you can supply localhost IP address (127.0.0.1)
aidin Tajadod 3-Oct-10 23:58pm    
What is the relation between server and server2? please send the complete error message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900