        @makeType()
        @uuid ]
 
-  # Create a UDP socket, send messages, then close socket.
-  sendMessages = (messages, address = '239.255.255.250', port = 1900) ->
+  # Queue for UDP messages to avoid hitting open file descriptor limit.
+  messageQueue = async.queue (task, callback) ->
+    { messages } = task
+    address = task.address ? '239.255.255.250'
+    port = task.port ? 1900
     socket = dgram.createSocket 'udp4'
     # Messages with specified destination do not need TTL limit.
     socket.setTTL 4 unless address?

    log.debug "Sending #{messages.length} messages to #{address}:#{port}."
    async.concat messages,
      (msg) -> socket.send msg, 0, msg.length, port, address
      -> socket.close()

  announce = (timeout = 1800) ->
    # To "kill" any instances that haven't timed out on control points yet,


  # Possible subtypes are 'alive' or 'byebye'.
  notify = (subtype) =>
    messageQueue.push messages: @makeSSDPMessage('notify',
        nt: nt, nts: "ssdp:#{subtype}", host: null
      ) for nt in @makeNotificationTypes()

  answer = (address, port) =>
    messageQueue.push { messages: @makeSSDPMessage('ok',
        st: st, ext: null
      ) for st in @makeNotificationTypes()
      address
      port
    }

  listen()
  announce()
