import os, time
read_path = "/tmp/pipe.in"
write_path = "/tmp/pipe.out"
if os.path.exists(read_path):
os.remove(read_path)
if os.path.exists(write_path):
os.remove(write_path)
os.mkfifo(write_path)
os.mkfifo(read_path)
rf = os.open(read_path, os.O_RDONLY)
wf = os.open(write_path, os.O_SYNC | os.O_CREAT | os.O_RDWR)
while True:
s = os.read(rf, 1024)
print "received msg: %s" % s
if len(s) == 0:
time.sleep(1)
continue
if "exit" in s:
break
os.write(wf, s)
os.close(rf)
os.close(wf)
import os
import time
write_path = "/tmp/pipe.in"
read_path = "/tmp/pipe.out"
wf = os.open(write_path, os.O_SYNC | os.O_CREAT | os.O_RDWR)
rf = None
for i in range(1, 11):
msg = "msg " + str(i)
len_send = os.write(wf, msg)
print "sent msg: %s" % msg
if rf is None:
rf = os.open(read_path, os.O_RDONLY)
s = os.read(rf, 1024)
if len(s) == 0:
break
print "received msg: %s" % s
time.sleep(1)
os.write(wf, 'exit')
os.close(rf)
os.close(wf)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有