 
 (declare boot)
 
+(on ::recv-osc-message (fn [msg]
+                         (dosync (ref-set recv-queue* (assoc @recv-queue* msg)))
+                         (println (str msg))))
+
+(on ::send-osc-message (fn [msg]
+                         (let [buffer (java.nio.ByteBuffer/allocate 8129)]
+                           (osc-encode-msg buffer msg)
+                           (.flip buffer)
+                           (World_SendPacket @world* (.limit buffer) buffer
+                                             (callback reply-cb
+                                                       (fn [addr buf size]
+                                                         (event ::recv-osc-message
+                                                                (osc-decode-packet (.getByteBuffer buf 0 size)))))))))
+
+(on ::send-osc-message-noreply (fn [msg]
+                                 (let [buffer (java.nio.ByteBuffer/allocate 8129)]
+                                   (osc-encode-msg buffer msg)
+                                   (.flip buffer)
+                                   (World_SendPacket @world* (.limit buffer) buffer nil))))
+
+(defn snd-nr
+  "Creates an OSC message and dont expect a reply back."
+  [path & args]
+    (cond 
+      (= ::external (type @server*)) (osc-send-msg @server* 
+                                                   (apply osc-msg path (osc-type-tag args) args))
+      (= ::internal (type @server*)) (event ::send-osc-message (apply osc-msg path (osc-type-tag args) args))))
+
 (defn snd
   "Creates an OSC message and either sends it to the server immediately
   or if a bundle is currently being formed it adds it to the list of messages."

      (recur (inc cnt))))
   (register-notification-handlers))

; TODO: setup an error-handler in the case that we can't connect to the server
(defn connect
  "Connect to an external SC audio server on the specified host and port."
  ([] (connect SERVER-HOST SERVER-PORT))
  ([host port] (.run (Thread. #(connect-thread host port)))))

(defonce running?* (atom false))


         (log/debug "Booting SuperCollider internal server (scsynth)...")
         (.start sc-thread)
         (dosync (ref-set server-thread* sc-thread))
         (connect :internal)
         :booting))))

(defn- sc-log 
