File: sync_udp_sender.py

package info (click to toggle)
python-txosc 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 304 kB
  • sloc: python: 1,857; makefile: 8
file content (23 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
"""
Example of a TCP txosc sender without Twisted.

This example is in the public domain.
"""
#FIXME: The txosc.sync.UdpSender is currently broken!

import socket # only for the exception type
from txosc import osc
from txosc import sync

if __name__ == "__main__":
    try:
        udp_sender = sync.UdpSender("localhost", 31337)
    except socket.error, e:
        print(str(e))
    else:
        udp_sender.send(osc.Message("/hello", 2, "bar", 3.14159))
        udp_sender.send(osc.Message("/ham/spam", "egg"))
        udp_sender.close()
        print("Successfully sent the messages.")