+ while (!_stopped) {
+ Socket socket = null;
+ try {
+ socket = tcpListener.AcceptSocket ();
+ socket.Send (_requestHandler (socket));
+ try {
+ socket.Shutdown (SocketShutdown.Receive);
+ socket.Shutdown (SocketShutdown.Send);
+ } catch {
+ }
+ } catch (SocketException ex) {
+ // ignore interruption of blocking call
+ if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS)
+ throw;
+ } finally {
+ Thread.Sleep (500);
+ if (socket != null)
+ socket.Close ();
+ }
+ }