private void StartListening() { ServerView serverView = new ServerView(); while (true) { Socket handler = ListenSocket.Accept(); Transfer transfer = new Transfer(this, handler); StringBuilder builder = new StringBuilder(); try { do { builder.Append(transfer.Listen()); TransferData transferData = TransferData.ConvertToTransferData(builder.ToString()); serverView.PerformCommand(transferData, transfer); } while (handler.Available > 0); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { handler.Shutdown(SocketShutdown.Both); handler.Close(); } } }