Skip to content

Instantly share code, notes, and snippets.

@daniel-bytes
Created January 5, 2014 16:56
Show Gist options
  • Save daniel-bytes/8270692 to your computer and use it in GitHub Desktop.
Save daniel-bytes/8270692 to your computer and use it in GitHub Desktop.
serialosc start method
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