A cohomological description of connections and curvature over posets