Exiting the listen()
Method
Calling the listen()
method of the tcpsocketserver object results in the
code in that thread halting at the call to the method until either an error occurs, the timeout expires,
or the break()
method of the tcpsocketserver object is called. At that
point, the original thread where the listen()
method was invoked will continue
execution. If that results in the object going out of scope, which would normally destroy the object, that
will only happen if no thread is running that was invoked via a connection to the object and no other
reference to the object still persists. A connection can be used to shutdown or restart the server if the
programmer chooses to implement such functionality. This would require that a reference to the server object
also be passed to the function that is called for each connection.