hmbdc
simplify-high-performance-messaging-programming
Main Page
Namespaces
Classes
Files
Examples
tcpcast.py
1
#Demonstrate how to use hmbdc's network functions in python
2
#Each hmbdc network communication module provides a console executable to interact with
3
#other languages other than C/C++, for example, console-tcpcast is for tcpcast module
4
#./console-tcpcast --help
5
# produce command documentation
6
#
7
#this progam sends and receive messages to itself using host loopback interface
8
import
subprocess
9
10
#Popen Console, so we can use console-tcpcast as a console to hmbdc-tcpcast functions
11
p = subprocess.Popen([
'/opt/hmbdc/bin/console-tcpcast'
,
'127.0.0.1'
], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
12
print
>> p.stdin,
"topic console"
#set current topic to be console
13
print
>> p.stdin,
"listen console"
#also subscribe to console topic so it hears itself in this case
14
print
>> p.stdin,
"ostr"
#print received message in string format
15
print
>> p.stdin,
"sendstr 1001 hello"
#send a message tagged 1001 with content hello in console topic
16
print
p.stdout.readline(),
#print out a message it receives - "1001 hello" since we listen to console
17
18
print
>> p.stdin,
"ohex"
#print received message in hex format
19
print
>> p.stdin,
"sendstr 1001 abcdefghijklmn"
20
print
p.stdout.readline(),
#see hex bytes
Generated by
1.8.11