def main(): # Create send port try: send = mach.Port() send.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Send port: {0}'.format(send) except mach.MachException, e: fail('Cannot create send port: {0}'.format(e))
if contents != 'Hello World': fail('Invalid message payload returned: {0}'.format(contents)) def main(): # Create send port try: send = mach.Port() send.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Send port: {0}'.format(send) except mach.MachException, e: fail('Cannot create send port: {0}'.format(e)) # Create receive port try: receive = mach.Port() receive.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Receive port: {0}'.format(receive) except mach.MachException, e: fail('Cannot create receive port: {0}'.format(e)) threading.Thread(target=server, args=(receive, )).start() msg = mach.Message() msg.bits = mach.make_msg_bits(mach.MessageType.MACH_MSG_TYPE_COPY_SEND, mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) msg.body = bytearray(struct.pack('256p', 'Hello World')) print 'Sent text: {0}'.format('Hello World') try: send.send(receive, msg) except mach.SendMessageException, e:
if contents != 'Hello World': fail('Invalid message payload returned: {0}'.format(contents)) def main(): # Create send port try: send = mach.Port() send.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Send port: {0}'.format(send) except mach.MachException, e: fail('Cannot create send port: {0}'.format(e)) # Create receive port try: receive = mach.Port() receive.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Receive port: {0}'.format(receive) except mach.MachException, e: fail('Cannot create receive port: {0}'.format(e)) # Create second receive port to pass try: second = mach.Port() second.insert_right(mach.MessageType.MACH_MSG_TYPE_MAKE_SEND) print 'Second receive port: {0}'.format(second) except mach.MachException, e: fail('Cannot create second receive port: {0}'.format(e)) t = threading.Thread(target=server, args=(receive,)) t.start()