//==================================================================
//函数名: senddata
//功能 :发送数据
//返回值:int
//输入参数:UINT,int,int,int,char*,sockaddr_in
//输出:int ret
//创建者:
//修改者:
//版本:
//创建日期:
//修改日期
//==================================================================
int CClientIPDlg::SendData(UINT index,int mod,int bmpsize,int frames,char* pSendBuf,sockaddr_in &addr)
{
char* pPackage;
int packsize = 0;
if ( mod = 0 ||index != frames-1)
{
packsize = 2+2+bmpsize+4+2+2+4;
}
else
packsize = 2+2+mod+4+2+2+4;
pPackage = new char[packsize];
*(WORD*)&pPackage[0] = index;
if (index != frames-1)
{
*(WORD*)&pPackage[2] = 0;
}
else
{
*(WORD*)&pPackage[2] = 1;
}
pSendBuf += bmpsize*index;
memcpy(&pPackage[4],pSendBuf,packsize-16);
*(int*)&pPackage[packsize-12] = bmpsize;
*(WORD*)&pPackage[packsize-8] = m_X;
*(WORD*)&pPackage[packsize-6] = m_Y;
*(int*)&pPackage[packsize-4] = packsize;
m_Confirm = FALSE;
int ret = sendto(m_Socket,pPackage,packsize,0,(sockaddr*)&addr,sizeof(addr));
delete[] pPackage;
return ret;
}