I try to send and receive data with NSOutputStream and NSInputStream in Swift. The sending of data is working well, but i have some questions about the receiving.
I foun
I am using the code written by hoedding, and noticed a mistake. The line:
var output = NSString(bytes: &buffer, length: buffer.count, encoding: NSUTF8StringEncoding)
should be replaced by:
var output = NSString(bytes: &buffer, length: len, encoding: NSUTF8StringEncoding)
You have to get in the output
var only the number of characters returned by the server, and not the full length of the buffer, or you will get garbage from previous requests.