import mypcap import threading class reciver(threading.Thread): def __init__(self,intrf,fname=None): self.intf=intrf self.fp=None if fname: self.fp=open(fname,"wb") threading.Thread.__init__(self) def run(self): self.intf.popen() while True: res,pkt=self.intf.read() if res>0: if self.fp: self.fp.write(str(pkt)) self.fp.write("\r\n") print pkt elif res<0: print res break self.fp.close() return int1=mypcap.interfaces() cnt =0 for itm in int1: cnt+=1 print cnt,":",itm t1=itm ##sel_int=int(raw_input("select inteface id:")) t1=int1[2] print t1,t1.desc r1=reciver(int1[2],"log1.txt") r1.start() ##t1.popen() ##print t1.write("master packet send by m.j") ##t1.pclose() r1.join()