diff options
Diffstat (limited to 'src/libs/client/OSCClientReceiver.cpp')
-rw-r--r-- | src/libs/client/OSCClientReceiver.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp index 0dbf49ec..45b8d794 100644 --- a/src/libs/client/OSCClientReceiver.cpp +++ b/src/libs/client/OSCClientReceiver.cpp @@ -50,15 +50,19 @@ OSCClientReceiver::start() if (_st != NULL) return; - if (_listen_port == 0) { - _st = lo_server_thread_new(NULL, error_cb); - _listen_port = lo_server_thread_get_port(_st); - } else { + // Attempt preferred port + if (_listen_port != 0) { char port_str[8]; snprintf(port_str, 8, "%d", _listen_port); _st = lo_server_thread_new(port_str, error_cb); } + // Find a free port + if (!_st) { + _st = lo_server_thread_new(NULL, error_cb); + _listen_port = lo_server_thread_get_port(_st); + } + if (_st == NULL) { cerr << "[OSCClientReceiver] Could not start OSC listener. Aborting." << endl; exit(EXIT_FAILURE); |