private void DisconnectClientSocket(SocketPacket socketData)
        {
            Socket LightSwitchClientsSocket = (Socket)socketData.m_currentSocket;
            try
            {
                // Remove the reference to the worker socket of the closed client so that this object will get garbage collected
                lock (LightSwitchClients)
                    LightSwitchClients.Remove(LightSwitchClientsSocket);

                LightSwitchClientsSocket.Close();
                LightSwitchClientsSocket = null;
            }
            catch (Exception e)
            {
                WriteToLog(Urgency.INFO, "Socket Disconnect: " + e);
            }
        }
 /// <summary>
 /// Waits for client data and handles it when recieved
 /// </summary>
 /// <param name="soc"></param>
 /// <param name="clientNumber"></param>
 /// <param name="verified"></param>
 public void WaitForData(System.Net.Sockets.Socket soc, int clientNumber, bool verified)
 {
     try
     {
         if (pfnWorkerCallBack == null)
         {
             // Specify the call back function which is to be invoked when there is any write activity by the connected client
             pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket(soc, clientNumber, verified);
         soc.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, pfnWorkerCallBack, theSocPkt);
     }
     catch (SocketException e)
     {
         WriteToLog(Urgency.ERROR, "Socket Exception: " + e);
     }
 }