[C#]TcpClient Problem...

I'm using this code:
Code:
public void startServer(MainForm main)
        {
            try
            {
                setUp(main);
                listener.Start(maxConnections);
                main.richTextBox1.Text += "[INFO] Server is listening on port 8680.";

                while (isRunning)
                {
                    if (listener.Pending())
                    {
                        if (connected < maxConnections)
                        {
                            accept = listener.AcceptTcpClient();

                            Utils.writeLine(main.richTextBox1, Utils.writeTime());
                            Utils.writeLine(main.richTextBox1, accept.Client.RemoteEndPoint + " is attempting to connect to the server.");
                            Utils.writeLine(main.richTextBox1, "Tending to the request...");
                            Thread newclient = new Thread(delegate() { createNewSessionThread(accept, ((IPEndPoint)accept.Client.RemoteEndPoint).Address.ToString()); });
                            newclient.Start();
                            connected++;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }

The first time I debugged it, i got a firewall notice that asked me if I wanted to unblock the services.

I clicked "Unblock", and now, whenever I debug, it just freezes when the startServer function is called.

Application error or firewall related?

EDIT: I just checked my firewall exceptions, and loginserver.exe and loginserver.vshost.exe are unblocked (I'm running Windows 7, and I have both Private and Public checked off.)

Step into the startServer function and see which line it's "freezing" on.

It's almost certainly an app error, and an easy way to check for future reference is to turn OFF the firewall, run it, and if it starts working magically, you know.
 
This is why you should use the Socket class, because TcpClient is synchronous and Socket is both asynchronous and synchronous.
 
Back