Created
January 5, 2014 16:56
-
-
Save daniel-bytes/8270692 to your computer and use it in GitHub Desktop.
serialosc start method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SerialOsc::start(Listener *listener) | |
{ | |
this->listener = listener; | |
if (listener == nullptr || listenSocket != nullptr) { | |
return; | |
} | |
for (int i = 0; i < portsToScan; i++) { | |
int tempPort = listenPort + i; | |
try { | |
listenSocket = new UdpListeningReceiveSocket( | |
IpEndpointName( IpEndpointName::ANY_ADDRESS, tempPort ), | |
this); | |
listenPort = tempPort; | |
std::cout << "Binding to port " << tempPort << "." << std::endl; | |
break; | |
} | |
catch(std::runtime_error &ex) { | |
// try next port | |
listenSocket = nullptr; | |
std::cerr << "Failed to bind to port " << tempPort << ". " << ex.what() << std::endl; | |
} | |
} | |
if (listenSocket != nullptr) { | |
thread = std::thread(&SerialOsc::runThread, this); | |
sendDeviceQueryMessage(); | |
sendDeviceNotifyMessage(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment