     var writeDataCount: Int = 0
     let writeDataMaxTimes = 100
     var totoalWroteDataLength: Int = -1
-    var totoalReadLength: Int = 0
+    
+    let dataWrote = NSMutableData()
+    let dataRead = NSMutableData()
 
     override func setUp() {
         super.setUp()
-        totoalReadLength = 0
         startEchoServer()
     }
     

//        XCTFail("Channel open operation should timed out")
//    }
    
    func testReadWrite() {
        do {
            let channel = try self.openDirectChannelWithTargetHost(echoHost, port: echoPort)
            XCTAssert(channel.isOpen)

            totoalWroteDataLength = (data?.length)! * writeDataMaxTimes
            for _ in 0..<writeDataMaxTimes {
                channel.writeData(data)
                dataWrote.appendData(data!)
            }
            
            waitForExpectationsWithTimeout(5) { error in
                if let error = error {
                    XCTFail(error.description)
                }
            }
            
            XCTAssertEqual(dataRead, dataWrote)
        } catch let error as NSError {
            XCTFail(error.description)
        }
