Questions tagged [nsstream]

NSStream is an abstract class for objects representing streams.

nsstream
Filter by
Sorted by
Tagged with
141 votes
18 answers
157k views

Objective-C: Reading a file line by line

What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of ...
user avatar
52 votes
3 answers
2k views

How to callback NSStreamDelegate with NSStreamEventOpenCompleted?

I have been working on a NSStreamDelegate, I have implemented call back, I have initialized the input and output stream ilke this... CFReadStreamRef readStream; CFWriteStreamRef writeStream; ...
Newbee's user avatar
  • 3,271
18 votes
2 answers
17k views

Receiving Data from NSInputStream in Swift

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 ...
hoedding's user avatar
  • 257
14 votes
4 answers
5k views

Buffering NSOutputStream used as NSInputStream?

I have this consumer class that takes an NSInputStream as argument which will be processed async, and I want to push data that comes from a producer class that requires that it has an NSOutputStream ...
cahlbin's user avatar
  • 1,049
14 votes
2 answers
1k views

Convert incoming NSStream to View

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/...
Eric's user avatar
  • 4,063
13 votes
1 answer
12k views

SWIFT ONLY -- Reading from NSInputStream [closed]

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 ...
johni's user avatar
  • 5,488
12 votes
2 answers
20k views

NSStream and Sockets, NSStreamDelegate methods not being called

I've followed the guide Setting Up Socket Streams and have effectively duplicated that code in my class. No matter what I try the delegate methods just don't seem to get called. In the header file I ...
arrtchiu's user avatar
  • 1,076
12 votes
3 answers
6k views

How to Transfer Large Files over wifi in iOS

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 ...
HarshIT's user avatar
  • 4,765
11 votes
1 answer
648 views

Enqueueing into NSInputStream?

I would like to add three "parts" to an NSInputStream: an NSString, an output from another stream and then another NSString. The idea is the following: The first and last NSStrings represent the ...
PeterD's user avatar
  • 642
9 votes
2 answers
4k views

Sending UIImage over NSOutputStream [closed]

I'm trying to send an image that user takes to the server. I get the JPEG representation, append that to the string needed to upload the photo, and then send the data through NSOutputStream. However, ...
Arman Shan's user avatar
9 votes
1 answer
2k views

Connecting to Redis server with NSStream in Swift

Hi everyone as the title mention I'm trying to send and receive data from my Redis server in swift language. I have done a lot of research and I can't come across a good answer about this topic, ...
Brian Nezhad's user avatar
  • 6,218
9 votes
1 answer
1k views

Is it possible to determine the NSRunLoop/NSThread that is associated with an open NSStream?

I am using (and am required to use) a third-party framework to which I do not have source. The third-party framework handles creating an authenticated client/server connection and hands back a pair of ...
xyzzycoder's user avatar
  • 1,831
9 votes
1 answer
3k views

How to properly open and close a NSStream on another thread

I have an application that connects to a server using NSStream on another thread. The application also closes the connection should the user decide to log out. The problem is that I am never able to ...
Seb's user avatar
  • 3,474
9 votes
2 answers
4k views

scheduleInRunLoop - threading network connections

I've not found any decent documentation that explains the threading process for NSStream. To be specific, let's go for NSInputStream. Threading in Objective-C to me is currently a mystery simply ...
Kieran Senior's user avatar
8 votes
2 answers
4k views

Warning:Comparison of constant 8 with expression of type XXXX is always false

I used ASIHTTPRequest in my project,but in the file ASIDataCompressor.m line 190: if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { if (err) { *err = [NSError ...
yellow's user avatar
  • 702
8 votes
1 answer
7k views

NSStream SSL on used socket

I am writing an application that uses NSStream's SSL functions on the iphone. I know that SSL is working because I can directly connect servers using SSL. I have encountered a problem where protocols ...
anurodhp's user avatar
  • 356
8 votes
5 answers
4k views

NSStreams Crashing Program!

All, I've run it down to this point by commenting, breakpoints, etc. The program crashes at the marked code. -(void) initNetworkCommunication { CFReadStreamRef readStream; CFWriteStreamRef ...
Baub's user avatar
  • 5,034
8 votes
2 answers
2k views

NSStreamDelegate not receiving NSStreamEvent.HasSpaceAvailable:

I had my code working in another project, in a class with the following signature: class ViewController: UIViewController, NSStreamDelegate, UITextFieldDelegate { Then I moved the connection to it'...
user83039's user avatar
  • 3,137
7 votes
1 answer
12k views

How to test if my remote socket NSStream are correctly open

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 ...
user avatar
7 votes
1 answer
2k views

Non-responsive stream delegate in Swift

So I was playing around with sockets in Swift and trying to connect the app with my server. I was having the app connect to the IP address of the server and used netcat on the server for testing. ...
cafemike's user avatar
  • 660
7 votes
1 answer
3k views

Memory Leaks in CFStreamCreatePairWithSocketToHost iOS

I use NSInputstream & NSOutputstream to setup a connection and send data. My stream object has a function to open and close the stream. I use the following code: @interface Stream() { ...
Jim Craane's user avatar
7 votes
1 answer
6k views

iPhone: Catching a Connection Error With NSStream

I have written a program that connects to a server on a given IP using the NSStream protocol outlined in Apple's stream programming guide. The connection and transfer of data works flawlessly, however ...
isometrik's user avatar
  • 419
7 votes
1 answer
3k views

NSStream Failing To Receive Data

I am making a chat application using NSStreams that connect to a simple c socket server. The stream connects successfully, and sends data, but it is unable to receive the data. Here is my Socket class ...
jamespick's user avatar
  • 1,972
7 votes
1 answer
785 views

iOS NSStream tcp server client can't communicate

I have an issue with the development of a tcp server/client in objective c with Bonjour. On the server side I open correctly the streams and I use the handleEvent function to send and receive data. ...
thegrandwaazoo's user avatar
7 votes
0 answers
306 views

Get connected service name using NSStream's and Bonjour based NSNetServices peer to peer

I have a problem with obtaining a connected service name on the other device. I am using NSNetServices based on Bonjour and input and output streams for peer to peer connections. I have an iPhone and ...
piotr_ch's user avatar
  • 508
6 votes
2 answers
21k views

Stream to Get Data - NSInputStream

All, I have a server that has a tcp socket stream for communication. I need to get to that stream and read the initial data that it needs to send me. My current code is as follows. To be honest, I'...
Baub's user avatar
  • 5,034
6 votes
2 answers
1k views

How to deal with concurrency issues brought by NSStream run loop scheduling using GCD?

I have the following situation where I create a GCD dispatch queue and in it I schedule an NSStream to the current NSRunLoop, as is required in its specification for it to emit delegate events, and ...
Matoe's user avatar
  • 2,750
6 votes
2 answers
2k views

how to pipe data from NSOutputStream to NSInputStream in objective-c

I have 2 libraries that I want to integrate and make them talk to each other. Each of them listen on their own input and output streams. Library 1 will be the transport layer for library 2. Case 1: ...
Sharath Ambati's user avatar
6 votes
1 answer
5k views

how to disable Nagle algorithm on TCP connection on iPhone

I'm building a socket , using CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) yourHostAsNSString, ...
gkedmi's user avatar
  • 61
6 votes
1 answer
3k views

How to configure CFStream (or NSStream) for SSL handshake?

I'm using CFStream/NSStream to make http connections. I want to be able to detect that a SSL handshake fails for three cases: case A: server is not trusted case B: server is trusted but asks a client ...
MohG's user avatar
  • 351
6 votes
2 answers
1k views

How to convert NSStream (NSInputStream / NSOutputStream) to SSL after stream opened?

I have NSInputStream and NSOutputStream from this code var readStream: Unmanaged<CFReadStream>? var writeStream: Unmanaged<CFWriteStream>? CFStreamCreatePairWithSocket(...
Adrian's user avatar
  • 273
6 votes
1 answer
2k views

External Accessory stream does not work 100% of the time

The input and output streams get opened all the time and the respective delegate methods get called with the correct NSStreamEvent code (NSStreamEventOpenCompleted). However, on some openSession ...
jason's user avatar
  • 134
6 votes
0 answers
2k views

NSStream streamError 57 - Socket is not connected happening intermittently and consistently

After making some changes to my app for iOS 6 (none of them actually pertaining to networking), I started encountering a strange error with my stream event handler. This is occurring on both iOS 5 and ...
John Hall's user avatar
  • 1,346
5 votes
2 answers
8k views

NSStream TCP Keep-alive iOS

I have written this code to setup a stream with a server: -(void)streamOpenWithIp:(NSString *)ip withPortNumber:(int)portNumber; { CFReadStreamRef readStream; CFWriteStreamRef ...
Jim Craane's user avatar
5 votes
1 answer
3k views

Problem with NSStream SSL Connection

I am using NSStream with SSL property for socket connection. It works fine when I use the local IP address such as 192.168.1.77. But if I use any server like www.xyz.com (it has SecurityLevelTLSv1), ...
Ramesh Pauldurai's user avatar
5 votes
1 answer
1k views

Disable Nagle's algorithm for NSOutputStream

I am creating a multiplayer game using MPCF. You control a spacehip on the iPad using the iPhone. I am experiencing various amount of lag and latency and buffering/pauses at random times and ...
bobmoff's user avatar
  • 2,444
5 votes
1 answer
2k views

bytesWritten, but other device never receives NSStreamEventHasBytesAvailable event

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. ...
Wienke's user avatar
  • 3,733
5 votes
3 answers
6k views

NSInputStream does not call Delegate (stream:handleEvent:)

I searched the web for a long time...I didn't find an answer for my issue, so I decided to post here. I try to establish a connection to a NNTP-server using NSStream. In a test-program, I open the ...
matrau's user avatar
  • 148
5 votes
0 answers
146 views

Writing to NSOutputStream cause high cpu usage

While instrumenting my app I found that CPU usage jumps to 90% when writing data to output stream. Specifically, when network speed is very high. When I profile it With Timer instrument, found that ...
K_Mohit's user avatar
  • 518
5 votes
1 answer
833 views

EXC_BREAKPOINT randomly using NSOutputStream

I'm writing an app which uses NSOutputStream. I init connection like this: delegate = self; CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost(NULL, (...
ibrig's user avatar
  • 51
5 votes
1 answer
2k views

iOS8 AVAudioEngine how to send microphone data over Multipeer Connectivity?

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 ...
Jacky Coolheart's user avatar
5 votes
0 answers
406 views

How to get low latency sending motion data between iOS devices, and what should I expect?

I want to control a space ship on the iPad using the accelerometer on an iPhone. The devices are connected using Multipeer Connectivity Framework. I am sending accelerometer data using the regular ...
bobmoff's user avatar
  • 2,444
5 votes
1 answer
2k views

iOS client/server implementation and "Operation now in progress" error

Background I have been kind of teaching myself about sockets and network programming from various sample code and the classic Unix Network Programming textbook while simultaneously trying to put the ...
RyanM's user avatar
  • 4,534
4 votes
1 answer
7k views

NSStream Handle Event Giving Status 4

I was trying on a TCP connection app, and I am getting a NSStreamEvent "4" on handleEvent. What am I doing wrong? My code is like, -(void) initNetworkCommunication { CFReadStreamRef readStream; ...
Srijith Vijayamohan's user avatar
4 votes
1 answer
3k views

NSOutputStream crashing with Bad Access after write (Objective-c)

I have been trying to get a basic TCP client up and running for my iOS application but have run into a block which i cannot seem to work my head around. So far i can connect, send a message which is ...
Jarmez De La Rocha's user avatar
4 votes
2 answers
3k views

Using NSXMLParser initWithStream: no parser delegate methods received

The basic problem I'm working on is using the NSStream classes to parse incoming incremental XML data. The data is never a complete XML Document, but I want to receive and process it in incremental ...
John Drake's user avatar
4 votes
1 answer
2k views

how to call NSStream Synchronously

How to call NSStream synchronously to get the results?? Presently I am getting a async call back in one of its delegate methods `(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)...
Shri's user avatar
  • 2,139
4 votes
1 answer
2k views

RN42 Bluetooth disconnects on iOS within seconds of streaming data

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 (...
Rami Alhamad's user avatar
4 votes
1 answer
2k views

Subclassing NSInputStream to upload a particular portion of data from a local filepath

I am having a 100 MB of data in a single file. This 100 mb data will be divided virtually. i.e., I need to create an NSInputStream which points to different 5MB chunks. This is possible by creating ...
Sj.'s user avatar
  • 1,714
4 votes
3 answers
3k views

How should you handle the possibility of an NSStream blockage?

Per Apple’s “Polling Versus Run-Loop Scheduling”: [hasSpace/BytesAvailable] can mean that there is available bytes or space or that the only way to find out is to attempt a read or a write ...
Wienke's user avatar
  • 3,733

1
2 3 4 5
7