Skip to content

Instantly share code, notes, and snippets.

@quiver
Created September 16, 2012 10:54
Show Gist options
  • Save quiver/3731968 to your computer and use it in GitHub Desktop.
Save quiver/3731968 to your computer and use it in GitHub Desktop.
Python port of half duplex FIFO program : http://developers.sun.com/solaris/articles/named_pipes.html
# Python port of half duplex FIFO program : http://developers.sun.com/solaris/articles/named_pipes.html
import sys
import config
def main():
if len(sys.argv) < 2:
print 'Usage : %s <string to be sent to the server>' % sys.argv[0]
sys.exit(0)
wr = open(config.HALF_DUPLEX, 'wb')
# write to the pipe
wr.write(sys.argv[1])
wr.close()
if __name__ == '__main__':
main()
# Python port of half duplex FIFO program : http://developers.sun.com/solaris/articles/named_pipes.html
HALF_DUPLEX = "/tmp/halfduplex"
# Python port of half duplex FIFO program : http://developers.sun.com/solaris/articles/named_pipes.html
import os
import config
def main():
os.mkfifo(config.HALF_DUPLEX, 0666)
# read from the pipe
rd = open(config.HALF_DUPLEX, 'rb')
buf = rd.read()
rd.close()
print 'Half Duplex Server:Rread From the pipe:%s' % buf
buf = buf.upper()
print 'Half Duplex Server:Converted String:%s' % buf
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment