cid is always going to give you the id of the connection your executing it on. If you want to associtate, say, a server with its id, loop through $scon or $scid.