/// <summary>
 /// Sends a byte[] to the client clientNum in the client list
 /// </summary>
 /// <param name="message"></param>
 /// <param name="clientNum"></param>
 public void SendMsg(byte[] message, int clientNum)
 {
     try
     {
         SocketPack socPak = (SocketPack)clientArrayList[clientNum - 1];
         if (socPak.clientSocket != null)
         {
             if (socPak.clientSocket.Connected)
             {
                 socPak.clientSocket.Send(message);
             }
         }
     }
     catch (SocketException se)
     {
         throw new Exception(se.ToString());
     }
 }
 /// <summary>
 /// Sends a string to the client clientNum in the client list
 /// </summary>
 /// <param name="message"></param>
 /// <param name="clientNum"></param>
 public void SendMsg(string message, int clientNum)
 {
     try
     {
         byte[]     byData = System.Text.Encoding.ASCII.GetBytes(message);
         SocketPack socPak = (SocketPack)clientArrayList[clientNum - 1];
         if (socPak.clientSocket != null)
         {
             if (socPak.clientSocket.Connected)
             {
                 socPak.clientSocket.Send(byData);
             }
         }
     }
     catch (SocketException se)
     {
         throw new Exception("Exception caught from SndMsg" + se.ToString());
     }
 }
        /// <summary>
        /// Establishes a wait for data event for a certain socket pack, and set the event handler
        /// </summary>
        /// <param name="socPak"></param>
        /// <param name="OnDataReceived"></param>
        public void WaitForData(SocketPack socPak, ExternalCallbackFunc OnDataReceived)
        {
            try
            {
                if (fncCallBack == null)
                {
                    // Specify the call back function which is to be
                    // invoked when there is any write activity by the
                    // connected client
                    fncCallBack = new AsyncCallback(OnDataReceived);
                }

                socPak.clientSocket.BeginReceive(socPak.dataBuffer, 0,
                                                 socPak.dataBuffer.Length,
                                                 SocketFlags.None,
                                                 fncCallBack,
                                                 socPak);
            }
            catch (SocketException)
            {
                throw new Exception("I can catch it");
            }
        }