File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,12 @@ ofxOscReceiver& ofxOscReceiver::copy(const ofxOscReceiver &other){
28
28
}
29
29
30
30
// --------------------------------------------------------------
31
- bool ofxOscReceiver::setup (int port) {
31
+ bool ofxOscReceiver::setup (int port, std::string host) {
32
32
if (listenSocket){ // already running
33
33
stop ();
34
34
}
35
35
settings.port = port;
36
+ settings.host = host;
36
37
return start ();
37
38
}
38
39
@@ -62,7 +63,7 @@ bool ofxOscReceiver::start() {
62
63
// create socket
63
64
osc::UdpListeningReceiveSocket *socket = nullptr ;
64
65
try {
65
- osc::IpEndpointName name (osc::IpEndpointName::ANY_ADDRESS , settings.port );
66
+ osc::IpEndpointName name (settings. host . c_str () , settings.port );
66
67
socket = new osc::UdpListeningReceiveSocket (name, this , settings.reuse );
67
68
auto deleter = [](osc::UdpListeningReceiveSocket*socket){
68
69
// tell the socket to shutdown
Original file line number Diff line number Diff line change 13
13
// / \struct ofxOscSenderSettings
14
14
// / \brief OSC message sender settings
15
15
struct ofxOscReceiverSettings {
16
- int port = 0 ; // /< port to listen on
17
- bool reuse = true ; // /< should the port be reused by other receivers?
18
- bool start = true ; // /< start listening after setup?
16
+ int port = 0 ; // /< port to listen on
17
+ std::string host = " 0.0.0.0" ; // /< host to listen on
18
+ bool reuse = true ; // /< should the port be reused by other receivers?
19
+ bool start = true ; // /< start listening after setup?
19
20
};
20
21
21
22
// / \class ofxOscReceiver
@@ -30,14 +31,14 @@ class ofxOscReceiver : public osc::OscPacketListener {
30
31
// / for operator= and copy constructor
31
32
ofxOscReceiver& copy (const ofxOscReceiver &other);
32
33
33
- // / set up the receiver with the port to listen for messages on
34
+ // / set up the receiver with the port (and specific host/ip) to listen for messages on
34
35
// / and start listening
35
36
// /
36
37
// / multiple receivers can share the same port if port reuse is
37
38
// / enabled (true by default)
38
39
// /
39
40
// / \return true if listening started
40
- bool setup (int port);
41
+ bool setup (int port, std::string host = " 0.0.0.0 " );
41
42
42
43
// / set up the receiver with the given settings
43
44
// /
You can’t perform that action at this time.
0 commit comments