// Send a ComData object public async Task SendLine(ComData comData) { // Only if active if (!IsActive) { return; } // Send the data try { var writer = new StreamWriter(networkStream); // Send the xml string await writer.WriteLineAsync(comData.GetXML()); writer.Flush(); } catch (IOException) { // socket closed Console.WriteLine("Server: Error Sending, marking as disconnected."); MarkAsDisconnected(); } }