Great tutorial. Observed one not so important typo the error message in āsendMessageā method says āError joining chatā guess it needs to be āError sending messageā or something
To close your connection, unschedule it from the run loop, set the connectionās delegate to nil (the delegate is unretained), close both of the associated streams with the close method, and then release the streams themselves (if you are not using ARC) or set them to nil (if you are). By default, this closes the underlying socket connection. There are two situations in which you must close it yourself, however:
If you previously set the kCFStreamPropertyShouldCloseNativeSocket to kCFBooleanFalse by calling setProperty:forKey: on the stream.
If you created the streams based on an existing BSD socket by calling CFStreamCreatePairWithSocket .By default, streams created from an existing native socket do not close their underlying socket. However, you can enable automatic closing by setting the kCFStreamPropertyShouldCloseNativeSocket to kCFBooleanTrue with the setProperty:forKey: method.
Good basic tutorial, but how do you handle exceptions? I used this method to do basic communications, but if the target IP address canāt be reached, the app hangs. Is there some sort of try-catch and timeout that can be set?