nsstream

NSStream - reverse DNS lookup error

柔情痞子 提交于 2019-12-11 08:23:05
问题 I have to open an NSStream to a wifi access point that has only a numerical address, not a name. It takes NSStream 30-40 seconds to open a socket. In experimenting, i found that telnet-ing to the AP from a windows box was instantaneous, but on a mac, connecting the same 30-40 seconds. in researching telnet, i found that the implementation is a little different on a mac, in that it by default tries to to a name lookup. reading the manual page for telnet, i found: -N Prevents IP address to name

How to use NSInputStream and NSOutputStream

人走茶凉 提交于 2019-12-10 18:01:42
问题 I am trying to create a simple multiplayer turn-based game between iPhones. Right now all I want to do is pass in some string to my method, and have the method send the string through the NSOutputStream . I think I have properly connected my NSNetServices using NSNetServiceBrowser . Once they connect, my NSNetServiceDelegate has netService:didAcceptConnectionWithInputStream:outputStream: called, which should give me my i/o NSStream pair. My method looks like this: -(void)netService:

bytesWritten, but other device never receives NSStreamEventHasBytesAvailable event

烈酒焚心 提交于 2019-12-10 14:42:41
问题 I have set up a Bonjour network between an iPhone and a Mac. The user chooses the iPhone’s net service in a table presented in the Mac, and a pair of streams are created and opened on both sides. The iPhone starts by sending a code (an integer) to the Mac. The Mac successfully receives it. After a pause for user input and processing, the Mac initiates sending a code to the iPhone: NSInteger bytesWritten = [self.streamOut write:buffer maxLength:sizeof(uint8_t)]; // bytesWritten is 1. But the

Convert incoming NSStream to View

為{幸葍}努か 提交于 2019-12-10 12:31:46
问题 I'm successfully sending a stream of NSData. The delegate method below is getting that stream and appending to NSMutableData self.data. How do I take this data and make it into a UIView/AVCaptureVideoPreviewLayer (which should show video)? I feel like I'm missing another conversion, AVCaptureSession > NSStream > MCSession > NSStream > ? - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { switch(eventCode) { case NSStreamEventHasBytesAvailable: { if(!self.data) { self.data

iOS: outputStream does not stay open

纵饮孤独 提交于 2019-12-10 12:19:34
问题 Okay so I'm implementing a NSOutput and Input Streams. When they are initialized, the streams open and connect to my TCPServer I have running on my PC, but then appear to close once outside of the initializing function or maybe the streams aren't being stored properly. I'm not quite sure so any assistance is greatly appreciated In my .h file: @interface AVCamViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate, NSStreamDelegate> { NSOutputStream

RN42 Bluetooth disconnects on iOS within seconds of streaming data

北慕城南 提交于 2019-12-09 13:22:58
问题 I've been trying to read data from a device via Bluetooth 2.1 using an RN-42. The device pairs to an iPhone or iPad Mini, and data is streamed across briefly, but the iOS & BT module disconnect (unpair) within seconds (less than 10). The device is outputting data 5-10kB/s, so well within Bluetooth’s spec. Something that I’ve also noticed is that when I run the function NSInputStream, [NSInputStream read: maxLength:], the number of bytes returned is always 158 or less. The app and hardware don

NSStream, UTF8String & NSString… Messy Conversion

和自甴很熟 提交于 2019-12-09 01:43:49
问题 I am constructing a data packet to be sent over NSStream to a server. I am trying to seperate two pieces of data with the a '§' (ascii code 167). This is the way the server is built, so I need to try to stay within those bounds... unichar asciiChar = 167; //yields @"§" [self setSepString:[NSString stringWithCharacters:&asciiChar length:1]]; sendData=[NSString stringWithFormat:@"USER User%@Pass", sepString]; NSLog(sendData); const uint8_t *rawString=(const uint8_t *)[sendData UTF8String];

NSTimer is not fired in time

自作多情 提交于 2019-12-08 09:31:27
问题 I am trying to connect to a port on a given IP Address. The one problem is that when a connection is established with a non existent IP Address the write command (which is as follows): NSData * imageRequest = [@"640" dataUsingEncoding: NSUTF8StringEncoding]; int image = [self.outputImageStream write:[imageRequest bytes] maxLength:[imageRequest length]]; It takes over 75 seconds to respond. I try dealing with this by starting a timer with the following method call: self.connectionTimeoutTimer

NSStream on iphone not working

空扰寡人 提交于 2019-12-08 07:04:47
问题 func connect(host: String, port: Int) { self.host = host self.port = port NSStream.getStreamsToHostWithName(host, port: port, inputStream: &inputStream, outputStream: &outputStream) if inputStream != nil && outputStream != nil { // Set delegate inputStream!.delegate = self outputStream!.delegate = self // Schedule inputStream!.scheduleInRunLoop(.mainRunLoop(), forMode: NSDefaultRunLoopMode) outputStream!.scheduleInRunLoop(.mainRunLoop(), forMode: NSDefaultRunLoopMode) // Open! inputStream!

NSStream receive NSStreamEventEndEncountered during opening

烂漫一生 提交于 2019-12-07 13:26:18
问题 I have a client - server app that uses NSStream to connect. sometimes when trying to open a connection, one side of the connection gets NSStreamEventEndEncountered when first trying to send a message. I use the bridge between CFStream and NSStream. My server create a socket with: _ipv4cfsock = CFSocketCreate(kCFAllocatorDefault,PF_INET, SOCK_STREAM,IPPROTO_TCP, kCFSocketAcceptCallBack, handleConnect, &info); In the handleConnect callback function, CFStreamCreatePairWithSocket is used to get