         socketEvent = GCDAsyncSocket(
             delegate:eventDelegate, delegateQueue:DispatchQueue.global(qos:DispatchQoS.QoSClass.background), socketQueue: DispatchQueue.global(qos:DispatchQoS.QoSClass.background))
         
+        let port:UInt16 = UInt16(deviceInfo.dataPort)!
+        
         do
         {
-            try socketCommand?.accept(onPort:UInt16(deviceInfo.dataPort)!)
+            try socketCommand?.accept(onPort:port)
         }
         catch let error
         {

    var socketCommand:GCDAsyncSocket?
    var socketEvent:GCDAsyncSocket?
    
    init(deviceInfo:DeviceInfo, connect:MConnect2)
    {
        self.deviceInfo = deviceInfo

        
        do
        {
            try socketEvent?.accept(onPort:port)
        }
        catch let error
        {
            print("error accept on port: \(error.localizedDescription)")
        }
        
        commandRequest()
    }
    
    func commandRequest()
    {
        var request:[CUnsignedChar] = [CUnsignedChar](repeating:0, count:ptpLength)
        let guid:[CUnsignedChar] = [CUnsignedChar](repeatElement(0, count:16))

        request[ptpip_type] = PTPIP_INIT_COMMAND_REQUEST
        request[ptpip_len] = ptpip_initcmd_name
        request[ptpip_initcmd_guid] = 1
        
        let data:Data = Data(bytes:request)
        
        socketCommand?.write(data, withTimeout:100, tag:0)
    }
}

