void SendJoinPacket()
        {
            UdpClient udpclient = new UdpClient(ServerPort);
            IPAddress multicastaddress = IPAddress.Parse(ServerIP);
            udpclient.JoinMulticastGroup(multicastaddress);
            IPEndPoint remoteep = new IPEndPoint(multicastaddress, ServerPort);

            while (true)
            {
                if (lstSendBuf.Count == 0) Thread.Sleep(1);
                else
                {
                    byte[] Buffer = null;
                    lock (lstSendBuf)
                    {
                        Buffer = lstSendBuf[0];
                        lstSendBuf.RemoveAt(0);
                    }

                    int FullSize = Buffer.Length;
                    byte NumPacket = (byte)(FullSize / MaxSizeBuf);
                    if (FullSize % MaxSizeBuf != 0)
                    {
                        NumPacket++;
                    }
                    byte CurPacket = 0;
                    int SendSize = 0;
                    MainIndexFrame++;

                    while (FullSize != 0)
                    {
                        if (FullSize > MaxSizeBuf)
                            SendSize = MaxSizeBuf;
                        else SendSize = FullSize;

                        var up = new UDP_Packet
                        {
                            Data = new byte[SendSize],
                            Index = MainIndexFrame,
                            NumPacket = NumPacket,
                            CurPacket = (CurPacket++)
                        };

                        Array.Copy(Buffer, Buffer.Length - FullSize, up.Data, 0, SendSize);

                        byte[] bSend = up.ToByte();
                        SendNumBytes += bSend.Length;
                        BytesDataRateSend += bSend.Length;
                        NumSendPacket++;
                        //      client_socket.BeginSendTo(bSend, 0, bSend.Length, SocketFlags.None,ipend, CallBackSend, client_socket);
                      //  client_socket.SendTo(bSend, ipend);
                        udpclient.Send(bSend, bSend.Length, remoteep);
                        FullSize -= SendSize;
                    }

                    if ((DateTime.Now - dt_dateRate).TotalMilliseconds >= 1000)
                    {
                        dt_dateRate = DateTime.Now;
                        BytesInSec = BytesDataRateSend;
                        BytesDataRateSend = 0;
                    }

                    if (lstSendBuf.Count > 1000)
                    {

                    }
                }
            }
        }
        public static UDP_Packet FromByte(byte[] BufIn, long size)
        {
            if(BufIn==null) return null;
            if(BufIn.Length<15) return null;
            UDP_Packet up = new UDP_Packet();
            bool bFlagPreambula = true;

            if (BufIn[0] != 251 ||
                BufIn[1] != 51 ||
                BufIn[2] != 250 ||
                BufIn[3] != 50)
                bFlagPreambula = false;
            int ind=4;

            up.Index |= BufIn[ind++]; up.Index <<= 8;
            up.Index |= BufIn[ind++]; up.Index <<= 8;
            up.Index |= BufIn[ind++]; up.Index <<= 8;
            up.Index |= BufIn[ind++];

            up.CurPacket |= BufIn[ind++]; up.CurPacket <<= 8;
            up.CurPacket |= BufIn[ind++];

            up.NumPacket |= BufIn[ind++]; up.NumPacket <<= 8;
            up.NumPacket |= BufIn[ind++];

            up.Size |= BufIn[ind++]; up.Size <<= 8;
            up.Size |= BufIn[ind++];
            up.Data = new byte[up.Size];
            Array.Copy(BufIn, ind, up.Data, 0, up.Size);
            up.timeRec = DateTime.Now;
            return up;
        }
        //*
        private void SendBuf(byte[] Buffer)
        {
            if (Buffer == null) return;
            // Creation Socket
            Socket client_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            // Conncet with the server
            IPEndPoint ipend = new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort);

            // Send the Text
            int FullSize = Buffer.Length;
            byte NumPacket = (byte)(FullSize/MaxSizeBuf);
            if(FullSize%MaxSizeBuf!=0)
            {
                NumPacket++;
            }
            byte CurPacket = 0;
            int SendSize = 0;
            MainIndexFrame++;

            while (FullSize!=0)
            {
                if (FullSize > MaxSizeBuf)
                    SendSize = MaxSizeBuf;
                else SendSize = FullSize;

                var up = new UDP_Packet
                                    {
                                        Data = new byte[SendSize],
                                        Index = MainIndexFrame,
                                        NumPacket = NumPacket,
                                        CurPacket = (CurPacket++)
                                    };

                Array.Copy(Buffer, Buffer.Length - FullSize, up.Data, 0, SendSize);

                byte[] bSend = up.ToByte();
                SendNumBytes += bSend.Length;
                BytesDataRateSend += bSend.Length;
                NumSendPacket++;
              //      client_socket.BeginSendTo(bSend, 0, bSend.Length, SocketFlags.None,ipend, CallBackSend, client_socket);
                client_socket.SendTo(bSend, ipend);
                FullSize -= SendSize;
            }

            // Conncetion Close
            client_socket.Close();

            if((DateTime.Now - dt_dateRate).TotalMilliseconds>=1000)
            {
                dt_dateRate = DateTime.Now;
                BytesInSec = BytesDataRateSend;
                BytesDataRateSend = 0;
            }
        }