public void Shutdown()
 {
     if (helper.IsConnected(serverSocket))
     {
         helper.ShutdownSocket(serverSocket);
     }
     helper.CloseSocket(serverSocket);
 }
        public void Send(Byte[] data)
        {
            lock (sendQueueLock)
            {
                sendQueue.AddRange(BitConverter.GetBytes(data.Length));
                sendQueue.AddRange(data);
            }

            if (!hasNetworkCycleStarted && helper.IsConnected(clientSocket))
            {
                hasNetworkCycleStarted = true;

                Byte[] outgoing = null;
                lock (sendQueueLock)
                {
                    outgoing = sendQueue.ToArray();
                    sendQueue.Clear();
                }

                helper.BeginSend(outgoing, new AsyncCallback(sendCallback), clientSocket);
            }
        }