 extension UDPClient : PacketSender {
   
   public var available : Bool {
-    return !socket.closed
+    return socket.isActive
   }
   
   public func send(packet: OSCConvertible) {
-    try? socket.write(packet.oscValue, deadline: 1.second.fromNow())
+    // FIXME - send packet.oscValue
   }
 }
 


public class UDPReceiver : PacketReceiver {
  
  let socket: UDPSocket

  let messageDecoder : MessageDecoder = decodeBytes

  public var available: Bool {
    return !socket.closed
  }
  
  public init(withSocket socket: UDPSocket) {
    self.socket = socket
  }

  
  // returns OSC packet received over UDP socket
  public func receivePacket() throws -> OSCConvertible? {
    guard !socket.closed else {
        return nil
    }
    
    let (buffer, _) = try socket.read(upTo: 1536, deadline: .never)
    
    return messageDecoder(buffer.bytes)
  }
}



public class UDPClient {

  public let socket: Socket

  public init(withSocket socket: Socket) {
    self.socket = socket
  }

  public convenience init?(localPort: Int, remotePort: Int) {
    guard
      let socket = try? Socket.create(family: .inet, type: .datagram, proto: .udp)
    else {
      return nil
    }
