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) {
                writeLog("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) {
         //log.Error("Socket Exception: " + e);
     }
 }