<commit_before>import UDP


public class OSCServer: MessageDispatcher {
  public typealias Message = OSCMessage

  let socket: UDPSocket
  let dispatcher = OSCMessageDispatcher

  public init(port: Int) throws {
    socket = try UDPSocket(ip: IP(port: port))
  }

  // override
  public func register(pattern: String, _ listener: @escaping (OSCMessage) -> Void) {
    dispatcher.register(pattern: pattern, listener)
  }

  // override
  public func unregister(pattern: String) {
    dispatcher.unregister(pattern: pattern)
  }

  // override
  public func dispatch(message: OSCMessage) {
    dispatcher.dispatch(message: message)
  }

  public func listen() {
    let deadline = 5.seconds.fromNow()

    while true {
      do {
        let (buffer, _) = try socket.read(upTo: 4096, deadline: deadline)

        let msg = OSCMessage(data: buffer.bytes )

        /// might crash during dispatch if message is garbled
        dispatcher.dispatch(message: msg)
      } catch {
        // DISPLAY SOME ERROR
        break
      }
    }
  }
}<commit_msg>Debug UDP errors<commit_after>import UDP


public class OSCServer: MessageDispatcher {
  public typealias Message = OSCMessage

  let socket: UDPSocket
  let dispatcher = OSCMessageDispatcher

  public init(port: Int) throws {
    socket = try UDPSocket(ip: IP(port: port))
  }

  // override
  public func register(pattern: String, _ listener: @escaping (OSCMessage) -> Void) {
    dispatcher.register(pattern: pattern, listener)
  }

  // override
  public func unregister(pattern: String) {
    dispatcher.unregister(pattern: pattern)
  }

  // override
  public func dispatch(message: OSCMessage) {
    dispatcher.dispatch(message: message)
  }

  public func listen() {
    let deadline = 5.seconds.fromNow()

    while true {
      do {
        let (buffer, _) = try socket.read(upTo: 4096, deadline: deadline)

        let msg = OSCMessage(data: buffer.bytes )

        /// might crash during dispatch if message is garbled
        dispatcher.dispatch(message: msg)
      } catch {
        // DISPLAY SOME ERROR
        print("Failed to read message \(error)")
        break
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.09720930232558139, 'fraction_numerical': 0.004651162790697674, 'mean_word_length': 2.7936507936507935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2533581', 'n_tokens_mistral': 664, 'n_tokens_neox': 623, 'n_words': 179}