BonCodeAJP13.BonCodeAJP13ServerConnection.p_CreateConnection C# (CSharp) Method

p_CreateConnection() private method

Create Actual Connection and initiate wait for response within this thread
private p_CreateConnection ( BonCodeAJP13.BonCodeAJP13PacketCollection packetsToSend ) : void
packetsToSend BonCodeAJP13.BonCodeAJP13PacketCollection
return void
        private void p_CreateConnection(BonCodeAJP13PacketCollection packetsToSend)
        {
            p_AbortConnection = false;
            p_ConnectionsCounter++;
            p_ThisConnectionID = p_ConnectionsCounter; //assign the connection id

            try
            {
                //create new connection and timer if we maintain connection timeout within this class
                if (p_TCPClient == null)
                {
                    p_TCPClient = new TcpClient(p_Server, p_Port);

                    p_KeepAliveTimer = new System.Timers.Timer();
                    p_KeepAliveTimer.Interval = BonCodeAJP13Consts.BONCODEAJP13_SERVER_KEEP_ALIVE_TIMEOUT;
                    p_KeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(p_KeepAliveTimer_Elapsed);
                    p_KeepAliveTimer.AutoReset = false;
                    p_KeepAliveTimer.Enabled = true; //starts the timer
                }
                //start p_StopWatch
                p_StopWatch.Start();

                //assign package and wait for response
                p_PacketsToSend = packetsToSend;

                //handle connection
                HandleConnection();
            }
            catch (Exception e)
            {
                if (p_Logger != null) p_Logger.LogException(e, "TCP Client level -- Server/Port:" + p_Server + "/" + p_Port.ToString());
                ConnectionError();
                string errMsg = "Connection to Tomcat has been closed. Tomcat may be restarting. Please retry later.";
                if (p_Logger != null)
                {
                    errMsg = errMsg + "<br><small>Administrator: please check your log file for detail on this error if needed.</small>";
                }
                else
                {
                    errMsg = errMsg + "<br><small>Administrator: please enable logging with log level 1 or greater for detail problem capture if needed.</small>";
                }

                if (BonCodeAJP13Settings.BONCODEAJP13_TOMCAT_TCPCLIENT_ERRORMSG.Length > 1) errMsg = BonCodeAJP13Settings.BONCODEAJP13_TOMCAT_TCPCLIENT_ERRORMSG;
                p_PacketsReceived.Add(new TomcatSendBodyChunk(errMsg));
                return;
            }
        }