- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { switch(eventCode) { case NSStreamEventHasBytesAvailable: { uint8_t buf[1]; unsigned int len = 0; while ((len = (uint8_t)[(NSInputStream *)stream read:buf maxLength:1])) { if (buf[0] == 0x00 || buf[0] == 0x0A || buf[0] == 0x0D) continue; [toProcess appendFormat:@"%c", buf[0], nil]; if ([toProcess hasSuffix:@"}"]) { NSLog(@"LINE: %@", toProcess); [toProcess setString:@""]; } } break; } } }