SwiftSocket
SwiftSocket copied to clipboard
readResponse is nil
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)
}`
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]? {