             {
                 return
             }
-            
+            // lenght must be exactly 8
             sock.write(data, withTimeout:100, tag:1957)
+            sock.readData(withTimeout:10000, tag:12)
+        }
+        else if method == "REGISTER"
+        {
+            /* REGISTER * HTTP/1.1\r\ndevice-id:681401e7aed401010101010101010101\r\ndevice-type:PS Vita\r\ndevice-mac-address:681401e7aed4\r\ndevice-name:vauxhal\r\npin-code:55852585\r\n\r\n */
+            
+            
         }
     }
     
     func socket(_ sock: GCDAsyncSocket, didConnectToHost host: String, port: UInt16) {
-        print("did connect")
-        
         print("did connect")
     }
     

        
        return compo2[0]
    }
}

        
        if method == "SHOWPIN"
        {
            pin = generatePin()
            
            print("pin \(pin)")
            
            let ok:String = "HTTP/1.1 200 OK\r\n"
            
            guard
