Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using socket listner to recieve data from client.
Is it posssible to replace the infinite loop while
// listen for incoming connections.
        try
        {
            listener.Bind(localEndPoint);
            listener.Listen(10);

            // Start listening for connections.
            while (true)//infinite loop
            {
            }
Posted

1 solution

Yes it is possible.

You could replace it with something like:

C#
bool runLoop = true;

while (runLoop)
{

//Some test here, if the test means the loops needs to end, set runLoop = false

}
 
Share this answer
 

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