ios - How can a client know that Server is sending some X bytes? -


let buffersize     = 4096             var buffer         = array<uint8>(count: buffersize, repeatedvalue: 0)             var message        = ""              while inputstream.hasbytesavailable {                 let len = inputstream.read(&buffer, maxlength: buffersize)                 if len < 0 {                     bblogerror("error reading stream...")                     return self.closestreams()                 }                 if len > 0 { //                    message += nsstring(bytes: &buffer, length: len, encoding: nsutf8stringencoding) as! string                     reciveddata.appendbytes(&buffer, length: buffersize)                     message += nsstring(bytes: &buffer, length: len, encoding: nsutf8stringencoding) as! string                 }                 if len == 0 {                     bblogerror("no more bytes available...")                     break                 }             } 

my situation: server sending 2 packets. how can client know server writing these many packets?


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -