private void ProcessSendFile(SocketAsyncEventArgs e)
        {
            var bytesRead = e.BytesTransferred;

            if (bytesRead > 0 && e.SocketError == SocketError.Success)
            {
                var receiveData = e.Buffer.Skip(e.Offset).Take(bytesRead).ToArray();
                var dataList    = PacketUtils.SplitBytes(receiveData, PacketUtils.ClientRequestFileTag());
                if (dataList != null)
                {
                    foreach (var request in dataList)
                    {
                        if (PacketUtils.IsPacketComplete(request))
                        {
                            int startPosition = PacketUtils.GetRequestFileStartPosition(request);

                            var packetSize = PacketUtils.GetPacketSize(_serverPath, _downloadChannelsCount);
                            if (packetSize != 0)
                            {
                                byte[] filedata     = FileUtils.GetFile(_serverPath, startPosition, packetSize);
                                byte[] packetNumber = BitConverter.GetBytes(startPosition / packetSize);

                                Console.WriteLine("Receive File Request PacketNumber: " + startPosition / packetSize);

                                if (filedata != null)
                                {
                                    //ready to send back to Client
                                    byte[] segmentedFileResponseData = PacketUtils.PacketData(PacketUtils.ServerResponseFileTag(), filedata, packetNumber);

                                    Array.Clear(e.Buffer, e.Offset, e.Count);
                                    Array.Copy(segmentedFileResponseData, 0, e.Buffer, e.Offset, segmentedFileResponseData.Length);

                                    e.Completed -= ProcessFilePosition_Completed;
                                    e.Completed += ProcessSendFile_Completed;

                                    if (!e.AcceptSocket.SendAsync(e))
                                    {
                                        CloseClientSocket(e);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                CloseClientSocket(e);
            }
        }
        private static void SendFileResponse(Socket handler, int startPosition)
        {
            var packetSize = PacketUtils.GetPacketSize(_serverPath, _downloadChannelsCount);

            if (packetSize != 0)
            {
                byte[] filedata     = FileUtils.GetFile(_serverPath, startPosition, packetSize);
                byte[] packetNumber = BitConverter.GetBytes(startPosition / packetSize);
                if (filedata != null)
                {
                    byte[]    segmentedFileResponseData = PacketUtils.PacketData(PacketUtils.ServerResponseFileTag(), filedata, packetNumber);
                    ComObject state = new ComObject {
                        WorkSocket = handler
                    };
                    handler.BeginSend(segmentedFileResponseData, 0, segmentedFileResponseData.Length, 0, SendFileResponseCallback, state);
                }
            }
            else
            {
                handler.Shutdown(SocketShutdown.Both);
                handler.Close();
            }
        }