'getHeader() -- grabs header information from the buffer an returns
it as a Header object.'

def getHeader(self):

    self.sendRequest(GET_HDR)
    (status, bufsize, payload) = self.receiveResponse()
    if (status == GET_ERR):
        return None
    if (status != GET_OK):
        self.disconnect()
        raise IOError('Bad    response    from    buffer    server    -    disconnecting')
    if (bufsize < 24):
        self.disconnect()
        raise IOError('Invalid    HEADER    packet    received    (too    few    bytes)    -    disconnecting')
    (nchans, nsamp, nevt, fsamp, dtype, bfsiz) = struct.unpack('IIIfII', payload[0:24])
    H = Header()
    H.nChannels = nchans
    H.nSamples = nsamp
    H.nEvents = nevt
    H.fSample = fsamp
    H.dataType = dtype
    if (bfsiz > 0):
        offset = 24
        while ((offset + 8) < bufsize):
            (chunk_type, chunk_len) = struct.unpack('II', payload[offset:(offset + 8)])
            offset += 8
            if ((offset + chunk_len) > bufsize):
                break
            H.chunks[chunk_type] = payload[offset:(offset + chunk_len)]
            offset += chunk_len
        if (CHUNK_CHANNEL_NAMES in H.chunks):
            L = H.chunks[CHUNK_CHANNEL_NAMES].split('\x00')
            numLab = len(L)
            if (numLab >= H.nChannels):
                H.labels = [x.decode('utf-8') for x in L[0:H.nChannels]]
    return H
