File: sync_tcp_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 (21 lines) | stat: -rwxr-xr-x 558 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
#!/usr/bin/env python
"""
Example of a TCP txosc sender without Twisted.

This example is in the public domain.
"""
import socket # only for the exception type
from txosc import osc
from txosc import sync

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