SwiftSocket icon indicating copy to clipboard operation
SwiftSocket copied to clipboard

readResponse is nil

Open unosbaghaie opened this issue 8 years ago • 1 comments

hi

in readResponse I have to sleep while response comes . If I comment slepp(3), response will be nil

What am I doing wrong?

`private func readResponse(from client: TCPClient) -> String? {
     //sleep(3)
    guard let response = client.read(1024*10) else {
        appendToTextField(string: " readResponse is nil")
        
        return nil
    }
    
    return String(bytes: response, encoding: .utf8)
}`

unosbaghaie avatar Nov 12 '17 17:11 unosbaghaie

In the TCPClient.swift (clickable) change timeout from -1 to 10

like:

 /*
  * read data with expect length
  * return success or fail with message
  */
 open func read(_ expectlen: Int, timeout: Int = 10) -> [Byte]? {

0xWDG avatar Dec 21 '17 20:12 0xWDG