This repository has been archived by the owner on Nov 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
osctest.php
75 lines (64 loc) · 1.84 KB
/
osctest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* proof of concept osc reciever
*
* start this script on a shell using php oscsend.php and enter some
* oscsend command on another.
*
* oscsend localhost 10000 /replay/status \
* iisisi 1 10047 "20110606-190002" 3600 "SGVsbGFzIFJhZGlvCg==" 1
* oscsend localhost 10000 /1/2 sss "asdf" "" "qwer"
* oscsend localhost 10000 /box/chan0 1
* oscsend localhost 10000 /box/chan1 0
* oscsend localhost 10000 // TTFFNNI 0 0 0 0 0 0 0
* oscsend localhost 10000 /SYN/0/1 im 2 000000ff
*
* PHP Version 5
*
* @category OscPhront
* @package Osc
* @subpackage Test
* @author Lucas S. Bickel <[email protected]>
* @copyright 2011 Lucas S. Bickel 2011 - Alle Rechte vorbehalten
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link http://osc.purplehaze.ch
*/
$debug = false;
$ip = 'localhost';
$port = 10000;
ini_set('include_path', 'src/:'.ini_get('include_path'));
/**
* load osc lib
*/
require_once 'src/Osc/Parse.php';
/**
* load broken hexfloat lib
*
* i plan on groking pack/unpack to the extent that i
* can do this right in Osc_Parse without needing this.
*/
require_once 'src/Osc/HexFloat.php';
// create a socket
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$r = socket_bind($socket, $ip, $port);
// loop until user interrupt
while (true) {
// this is what gets each datagram
if (socket_recvfrom($socket, $b, 9999, 0, $f, $p)) {
// a parser gets instanciated for each datagram
$osc = new Osc_Parse;
$osc->setDebug($debug);
// pass the datagram buffer
$osc->setDataString($b);
// start the parser
$osc->parse();
// make some output
if ($debug) {
var_dump($osc);
}
$r = $osc->getResult();
$r["sourceip"] = $f;
$r["sourceport"] = $p;
var_dump($r);
}
}