Hello,
I'm porting the ping example from the winsock2 book to powerbasic. The problem I'm running in to is the InternetChecksum function. I know C++ a little, but I find this function difficult to convert to the powerbasic language. Maybe I could do it but I want to make sure that the function is correct, clean and fast
.
The definition of the function is "the one's complement of the one's complement sum of all 16 bit words"
So if somebody could help me with this I will be very thankfull.
Ok this is the C function. I'm only intrested in the code that's inside the function. The parameters are : 1. A type 2. len of type (sizeof).
USHORT InternetChecksum(PUSHORT pBuf, int nLen)
{
int nSum = 0;
While(nlen > 0)
{
nSum += (*pBuf++);
nLen -= 2;
}
nSum = (nSum > 16) + (nSum & 0xffff);
nSum += (nsum > 16);
return(~nSum);
}
The checksum is a standard from RFC 791 IP.
Any help is appreciated even if it is a little.
Thanks
[This message has been edited by cyclone atom (edited March 05, 2000).]
I'm porting the ping example from the winsock2 book to powerbasic. The problem I'm running in to is the InternetChecksum function. I know C++ a little, but I find this function difficult to convert to the powerbasic language. Maybe I could do it but I want to make sure that the function is correct, clean and fast

The definition of the function is "the one's complement of the one's complement sum of all 16 bit words"
So if somebody could help me with this I will be very thankfull.
Ok this is the C function. I'm only intrested in the code that's inside the function. The parameters are : 1. A type 2. len of type (sizeof).
USHORT InternetChecksum(PUSHORT pBuf, int nLen)
{
int nSum = 0;
While(nlen > 0)
{
nSum += (*pBuf++);
nLen -= 2;
}
nSum = (nSum > 16) + (nSum & 0xffff);
nSum += (nsum > 16);
return(~nSum);
}
The checksum is a standard from RFC 791 IP.
Any help is appreciated even if it is a little.
Thanks
[This message has been edited by cyclone atom (edited March 05, 2000).]
Comment