Note that there are some explanatory texts on larger screens.

plurals
  1. POTcpClient doesn't connect, program freezes, server does not receive anything
    primarykey
    data
    text
    <pre><code> static void tcp() { MessageBox.Show("Beginning..."); System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse("127.0.0.1"); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 20061); TcpClient connection = new TcpClient(); connection.Connect(ipEndPoint); NetworkStream stream = connection.GetStream(); var reader = new StreamReader(stream); var writer = new StreamWriter(stream); writer.WriteLine("/api/subscribe?source=console&amp;key=d41c411558628535bbad927b1ad667c823e37a7e06e1b0a61ce707ed287bb4bb&amp;show_previous=true"); writer.Flush(); var line = reader.ReadLine(); if (line != "success") throw new InvalidOperationException("Failed to connect"); while ((line = reader.ReadLine()) != null) { MessageBox.Show(line); Program.Form3 Form3 = new Program.Form3(); Form3.textBox1.Text = Form3.textBox1.Text + "\r\n" + line; } } </code></pre> <p>This the code I got. I want to connect to my server waiting for requests over TCP. However, this code does not work, and I can't figure out why. When it was on main thread, the program was just freezing. Now, when it's on another thread (tcp()) nothing actually happens, and the server does not even receive anything.</p> <p><strong>I checked if the server is fully working and operational, it 100% works.</strong> I checked using SimpleTCP. (I connected to 127.0.0.1 over port 20061, and sent a command "/api/subscribe?source=console&amp;key=d41c411558628535bbad927b1ad667c823e37a7e06e1b0a61ce707ed287bb4bb&amp;show_previous=true", and started receiving strings I wanted.)</p> <p>I just want to connect to TCP, send one command, and start receiving strings.</p> <p>Oh, and I sure do call the thread, when I hit button "connect" the message box shows up.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload