     }
     var nsdata : Data {
         get {
-            return Data(bytes: UnsafePointer<UInt8>(ptr), count: count)
+            return Data(bytes: ptr, count: count)
         }
         set {
             count = 0
-            append(UnsafePointer<UInt8>((newValue as NSData).bytes), length: newValue.count)
+            append((newValue as NSData).bytes.bindMemory(to: UInt8.self, capacity: newValue.count), length: newValue.count)
         }
     }
     var buffer : UnsafeBufferPointer<UInt8> {

    }

    func openConn() throws {
        var req = request! //.mutableCopy() as! NSMutableURLRequest
        req.setValue("websocket", forHTTPHeaderField: "Upgrade")
        req.setValue("Upgrade", forHTTPHeaderField: "Connection")
        if req.value(forHTTPHeaderField: "User-Agent") == nil {

                }
                if bufsiz == 0 {
                    bufferSize *= 2
                    let nbuf = realloc(buffer, bufferSize).assumingMemoryBound(to: UInt8.self)
                    buffer = nbuf
                    buf = buffer!+Int(buflen)
                    bufsiz = bufferSize - buflen
