I am very new to network programming and I'm thinking I have probably misconstrued the creation of an appropriate TCP listener. The code I have below works perfectly, but I have a feeling it's a hack and slash miracle and could come apart easily when set into my production environment. What can I do to improve this receive message? ObjectiveThe application should be able to receive a string and parse it into an xml string. Later, after a set of validation and data collection is completed, a response will be sent back to the client.Receive Messageprivate static void ReceivePortMessages(){    int requestCount = 0;    tcpListener.Start();    Debug.Print( >> Server Started);    tcpClient = tcpListener.AcceptTcpClient();    Debug.Print( >> Accept connection from client);    while (true)    {        try        {            requestCount = requestCount++;            NetworkStream networkStream = tcpClient.GetStream();            byte[] bytesFrom = new byte[10025];            networkStream.Read(bytesFrom, 0, (int)tcpClient.ReceiveBufferSize);            Stopwatch sw = new Stopwatch();            sw.Start();            string dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom);            dataFromClient = dataFromClient.Substring(0, dataFromClient.IndexOf(\0));            XmlDocument xm = new XmlDocument();            xm.LoadXml(string.Format(<root>{0}</root>, dataFromClient));            XmlElement root = xm.DocumentElement;            string rootName = root.FirstChild.Name;            RouteInboundXML(rootName, dataFromClient, sw);        }        catch (ArgumentOutOfRangeException ex)        {            Debug.Print(ReceivePortMessages: Remote client disconnected.  + ex.ToString());            tcpClient.Close();            tcpListener.Stop();            ReceivePortMessages();            return;        }        catch (Exception ex)        {            Debug.Print(ReceivePortMessages:  + ex.ToString());            tcpClient.Close();            tcpListener.Stop();            ReceivePortMessages();            return;        }        Debug.Print( >> exit);    }}Send Messageprivate void SendReply(string reply){    try    {        NetworkStream networkStream = _TcpClient.GetStream();        string serverResponse = reply;        Byte[] sendBytes = Encoding.ASCII.GetBytes(serverResponse);        networkStream.Write(sendBytes, 0, sendBytes.Length);        networkStream.Flush();        Debug.Print( >>  + serverResponse);    }    catch (ArgumentOutOfRangeException ex)    {        Debug.Print(SendReply: Remote client disconnected.  + ex.ToString());        _TcpClient.Close();        _TcpListener.Stop();        ReceivePortMessages();        return;    }}
Creating a TCP Listener and receiving data
c#;socket;tcp