| CSpoofSocket:: CalculateChecksum() |

Protected Function | Declared in: SpoofSocket.h

## Declaration

    unsigned short CalculateChecksum(
        const unsigned short* usBuf,
        int iSize) const;

## Description

Calculate the data checksum

## Function Body

    try
    {
        unsigned long usChksum=0;

        //Calculate the checksum
        while (iSize>1)
        {
            usChksum+=*usBuf++;
            iSize-=sizeof(unsigned short);
        }

        //If we have one char left
        if (iSize)
            usChksum+=*(unsigned char*)usBuf;

        //Complete the calculations
        usChksum=(usChksum >> 16) + (usChksum & 0xffff);
        usChksum+=(usChksum >> 16);

        //Return the value (inversed)
        return (unsigned short)(~usChksum);
    }
    ERROR_HANDLER_RETURN("CalculateChecksum",0)

## See Also

Class Overview | CSpoofBase | Hierarchy Chart

This web site was generated using Surveyor V4.50.811.1. Click here for more information. | Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 27 Jun 2001.