i'm new to vc++.net...I'm doing a project to send a packet to another machine like ping command...in this i'm using sendto() function..i have to convert all the class parametes to char*...
my code is ..
i tried using marshall copy function but it wont work....what i'll do to correct this problem....
my code is ..
Code:
int SendEchoRequest(SOCKET s, LPSOCKADDR_IN lpstToAddr)
{
ECHOREQUEST &echoreq=*new ECHOREQUEST;
static nID=1;
static nSeq=1;
int nRet;
echoreq.IcmpHDR->Type=ICMP_ECHOREQ;
Console::WriteLine(S"Type :{0}",echoreq.IcmpHDR->Type.ToString());
echoreq.IcmpHDR->Code=0;
echoreq.IcmpHDR->Checksum=0;
echoreq.IcmpHDR->ID=nID++;
echoreq.IcmpHDR->Seq_no=nSeq++;
for(nRet=0;nRet<REQ_DATASIZE;nRet++)
{
echoreq.Cdata[nRet]=' '+nRet;
}
echoreq.dwTime=GetTickCount();
const char *buffer;
int length;
System::Runtime::InteropServices::Marshal::Copy(echoreq,0,buffer,length);
//echoreq->IcmpHDR->Checksum =in_cksum((unsigned short *)&echoreq,echoreq->ToString()->get_Length());
nRet=sendto(s,buffer,length,0,(LPSOCKADDR)lpstToAddr,sizeof(SOCKADDR_IN));
if (nRet == SOCKET_ERROR)
ReportError("sendto()");
return (nRet);
}
Comment