def _write_header(self, pkt):
self.header_present=1
if self.append:
# Even if prone to race conditions, this seems to be
# safest way to tell whether the header is already present
# because we have to handle compressed streams that
# are not as flexible as basic files
g = [open,gzip.open][self.gz](self.filename,"rb")
if g.read(16):
return
self.f.write(struct.pack(self.endian+"IHHIIII", 0xa1b2c3d4L,
2, 4, 0, 0, MTU, self.linktype))
self.f.flush()
评论列表
文章目录