Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions addons/ofxOsc/src/ofxOscReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ ofxOscReceiver& ofxOscReceiver::copy(const ofxOscReceiver &other){
}

//--------------------------------------------------------------
bool ofxOscReceiver::setup(int port){
bool ofxOscReceiver::setup(int port, std::string host) {
if(listenSocket){ // already running
stop();
}
settings.port = port;
settings.host = host;
return start();
}

Expand Down Expand Up @@ -62,7 +63,7 @@ bool ofxOscReceiver::start() {
// create socket
osc::UdpListeningReceiveSocket *socket = nullptr;
try{
osc::IpEndpointName name(osc::IpEndpointName::ANY_ADDRESS, settings.port);
osc::IpEndpointName name(settings.host.c_str(), settings.port);
socket = new osc::UdpListeningReceiveSocket(name, this, settings.reuse);
auto deleter = [](osc::UdpListeningReceiveSocket*socket){
// tell the socket to shutdown
Expand Down
11 changes: 6 additions & 5 deletions addons/ofxOsc/src/ofxOscReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
/// \struct ofxOscSenderSettings
/// \brief OSC message sender settings
struct ofxOscReceiverSettings {
int port = 0; ///< port to listen on
bool reuse = true; ///< should the port be reused by other receivers?
bool start = true; ///< start listening after setup?
int port = 0; ///< port to listen on
std::string host = "0.0.0.0"; ///< host to listen on
bool reuse = true; ///< should the port be reused by other receivers?
bool start = true; ///< start listening after setup?
};

/// \class ofxOscReceiver
Expand All @@ -30,14 +31,14 @@ class ofxOscReceiver : public osc::OscPacketListener {
/// for operator= and copy constructor
ofxOscReceiver& copy(const ofxOscReceiver &other);

/// set up the receiver with the port to listen for messages on
/// set up the receiver with the port (and specific host/ip) to listen for messages on
/// and start listening
///
/// multiple receivers can share the same port if port reuse is
/// enabled (true by default)
///
/// \return true if listening started
bool setup(int port);
bool setup(int port, std::string host = "0.0.0.0");

/// set up the receiver with the given settings
///
Expand Down