nsstream

RN42 Bluetooth disconnects on iOS within seconds of streaming data

和自甴很熟 提交于 2019-12-03 16:45:12
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’t crash, but the Bluetooth just unpairs. The device is still sending data to the RN42 even after the

how to disable Nagle algorithm on TCP connection on iPhone

我是研究僧i 提交于 2019-12-03 15:02:05
I'm building a socket , using CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) yourHostAsNSString, yourPortAsInteger, &myReadStream, &myWriteStream); and I see that when I send a messages with "myWriteStream" it concatenate few message together and then send them. I think it happens because of the Nagle algorithm and I want to disable it. Does any one knows how to do it? No guarantee this will fix your problem, but if you want to disable the Nagle algorithm, you need to get the native socket from the stream and call setsockopt . CFDataRef nativeSocket =

How to Transfer Large Files over wifi in iOS

别等时光非礼了梦想. 提交于 2019-12-03 11:20:26
I downloaded WiTap Code From Apple's website. Its for transferring data over local wifi network. I am working in a project to interact as client - server architecture. I am sending NSData from client side to server. I made 2 projects; one for client and one for server At client side project, i made following Changes For that I modified the AppController.m file by adding following method AppController.m (Client side) - (void)sendData:(NSData*)pobjData { assert(self.streamOpenCount == 2); if ( [self.outputStream hasSpaceAvailable] ) { NSInteger bytesWritten; NSUInteger length = [pobjData length]

NSURLRequest with HTTPBody input stream: Stream sends event before being opened

白昼怎懂夜的黑 提交于 2019-12-03 10:03:46
I want to send a large amount of data to a server using NSURLConnection (and NSURLRequest ). For this I create a bound pair of NSStream s (using CFStreamCreateBoundPair(...) ). Then I pass the input stream to the NSURLRequest ( -setHTTPBodyStream: ) and schedule the output stream on the current run loop. When the run loop continues, I get the events to send data and the input stream sends this data to the server. My problem is, that this only works when the data fits into the buffer between the paired streams. If the data is bigger, then somehow the input stream gets an event (I assume "bytes

SWIFT ONLY — Reading from NSInputStream [closed]

放肆的年华 提交于 2019-12-03 09:13:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Could you please explain me how do I read properly from an NSInputStream? I couldn't understand what is UnsafePointer and what's the use of it (also for UnsafeArray). The NSInputStream read function gets an CMutablePointer which can be filled with an UnsafePointer object. It's a real mess comparing

How to test if my remote socket NSStream are correctly open

最后都变了- 提交于 2019-12-03 07:53:03
问题 TL;DR : What's the way to check if my remote stream are opened correctly after a call to NSStream.getStreamsToHostWithName(...) ? My application is a mobile IOS8 swift application. I am using NSStream for input and output socket communication with a remote server. To connect to my server and open my stream I use this code: func connect(host: String, port: Int) -> Bool { //clear the previous connection if existing (and update self.connected) disconnect() //updating the current connection self

Receiving Data from NSInputStream in Swift

我是研究僧i 提交于 2019-12-03 03:49:26
问题 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 found a solution with handling the NSStreamEvent, which i have tried. First of all my function for initializing the connection: func initNetworkCommunication(){ var host : CFString = "127.0.0.1" var port : UInt32 = 7001 var readstream : Unmanaged<CFReadStream>? var writestream : Unmanaged<CFWriteStream>?

Receiving Data from NSInputStream in Swift

不羁的心 提交于 2019-12-02 17:14:50
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 found a solution with handling the NSStreamEvent, which i have tried. First of all my function for initializing the connection: func initNetworkCommunication(){ var host : CFString = "127.0.0.1" var port : UInt32 = 7001 var readstream : Unmanaged<CFReadStream>? var writestream : Unmanaged<CFWriteStream>? CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, &readstream, &writestream) inputstream = readstream!

NSOutputStream flushing

懵懂的女人 提交于 2019-12-01 08:47:25
I'm working on an iPhone App and wanted to use: CFStreamCreatePairWithSocketToHost(NULL, url, port, &serverReadStream, &serverWriteStream); And after that use the: [serverWriteStream write:[sendData bytes] maxLength:[sendData length]]; I want to send small Packages of 5 Bytes to get realtime updates. My problem is now, that the stream only sends data when the buffer is full. So I need some kind of a flush method or tell the stream to immediately send the data. Searching for this problem ended in finding 'TCP_NODELAY' which seems to belong to the undocumented API ( which I mustn't use for

iOS8 AVAudioEngine how to send microphone data over Multipeer Connectivity?

送分小仙女□ 提交于 2019-11-30 21:10:51
I want to send microphone audio data over Multipeer Connectivity (iOS 8) and play it through the speaker of the receiving peer. I've also setup the AVAudioEngine and I can hear the microphone data from the (upper) speaker output, but I don't know how to send AVAudioPCMBuffer over the network. Here's my code snippet: AVAudioInputNode *inputNode =[self.engine inputNode]; AVAudioMixerNode *mainMixer = [self.engine mainMixerNode]; [self.engine connect:inputNode to:mainMixer format:[inputNode inputFormatForBus:0]]; [mainMixer installTapOnBus:0 bufferSize:4096 format:[mainMixer outputFormatForBus:0]