Questions tagged [nsinputstream]

NSInputStream is an Objective-C class on iOS , a subclass of NSStream that provides read-only stream functionality. NSInputStream is “toll-free bridged” with its Core Foundation counterpart, CFReadStreamRef.

150 questions
2
votes
0 answers

Trying to use GCDAsyncSocket for buffered transfer

(UPDATED) I am trying to read a large file ( a video or a picture) and send it to a remote server via a SOAP request. I need to encode the data as a Base64 string. I am trying to do this as follows: Create a template xml for the SOAP request that…
PeterD
  • 642
  • 1
  • 6
  • 17
2
votes
2 answers

How to read a NSInputStream with UTF-8?

I try to read a large file in iOS using NSInputStream to separate the files line by newlines (I don't want to use componentsSeparatedByCharactersInSet as it uses too much memory). But as not all lines seem to be UTF-8 encoded (as they can appear…
Kreisquadratur
  • 999
  • 8
  • 26
2
votes
1 answer

How to correctly measure NSInputStream data rate

I'm trying to measure actual transfer speed during ftp download, download itself is working, streams are hooked up in run loop. Measurment is done in NSStreamEventHasBytesAvailable using CFTimeGetCurrent on event start and at the end, after data is…
user1431796
1
vote
0 answers

Cocoa: POSTing a (very) large file

In Cocoa, how would you go about POSTing a file big enough to cause allocation issues while still appending the Content-Disposition and Content-Type flags in code? Right now, we're allocating an NSMutableURLRequest, setting the headers, initializing…
Anonymous
  • 1,750
  • 3
  • 16
  • 21
1
vote
1 answer

NSInputStream in background thread doesn't call NSStreamEventHasBytesAvailable

I am working on streaming part of application. I needed to put streaming process on the background thread that it uses NSinputstream and NSOutputstream . then I send http commands over this streaming channel on the same thread. I receive the…
1
vote
0 answers

Streaming between two NSURLConnections, blocking NSInputStream read blocks all connections?

I'm trying to stream data between two iOS NSURLConenctions (one downloading, the other uploading), but can't seem to make it work. I have two NSURLConnections running simultaneously. One is downloading content from a url using a GET request. The…
imre
  • 1,667
  • 1
  • 14
  • 28
1
vote
1 answer

NSInputStream read:maxBytes always returns 0

I'm baffled. I have an open NSInputStream which thinks it has bytes available. When I read the bytes, the operation always returns 0. I've searched everywhere and my code looks like most everyone else's doing the same thing. This is such a low…
user845037
  • 19
  • 3
1
vote
0 answers

Swift: Read/Write & connection problems with I/O streams and URLSessionStreamTask

Context I am trying to create a communication channel based on Bonjour NetService and URLSessionStreamTask to open the I/O stream. I have the setup ready and I am able to connect with bonjour service and open I/O streams between mac and iOS app. I…
Jasveer Singh
  • 354
  • 3
  • 10
1
vote
1 answer

Can NSInputStream be used to read chunks of data with offset to be able to upload large files

I’d like to know if there is a way to use NSInputStream to read chunk of data with some offset. For example there is a file with size 100MB, I need chunks with size of 10MB but I need the 5th chunk before the 1st chunk. The goal is to be able to…
surToTheW
  • 772
  • 2
  • 10
  • 34
1
vote
2 answers

Memory issue while converting big video file path to NSData. How to use InputStream/FileHandle to fix this issue?

I have a large sized video saved in my documents directory. I want to retrieve this video and remove it's first 5 bytes. For large video files of above 300 MB using [NSData(contentsOf: videoURL)] causing Memory issue error. I have gone through…
Sona
  • 394
  • 3
  • 15
1
vote
0 answers

InputStream never calls hasBytesAvailable

I'm trying to get iOS devices to discover each other with Bonjour and then connect with InputStream and OutputStream. The devices can connect to each other, but sending bytes from one device's OutputStream will not trigger the "hasBytesAvailable"…
1
vote
1 answer

How convert NSInputStream to UIImage

I have an NSInputStream that I'm sending to server and while upload is going on, I want to display image that's uploading. Method is located in singleton and it's receiving that NSInputStream. Is there a way to read that stream and convert it to…
Srdjan
  • 106
  • 10
1
vote
2 answers

Video streaming via NSInputStream and NSOutputStream

Right now I'm investigating possibility to implement video streaming through MultipeerConnectivity framework. For that purpose I'm using NSInputStream and NSOutputStream. The problem is: I can't receive any picture so far. Right now I'm trying to…
1
vote
0 answers

What's the best way to consume the bytes of NSData?

I'd like to parse some binary data. In Java I would use ByteBuffer class, which has really nifty methods like getInt(), getChar(), etc. which will return you the correct length of data, and advance the (internal) "read head". The closest I could…
Alexander
  • 59,041
  • 12
  • 98
  • 151
1
vote
1 answer

Bytes are changed after encoding NSString into NSInputStream via NSData

I run into the following problem when trying encoding an NSString as NSString -> NSData -> NSInputStream and then decode from NSInputStream with read method: NSString *inputString = [NSString stringWithFormat:@"%c", 255]; NSData *data = [inputString…
yvetterowe
  • 1,239
  • 7
  • 20
  • 34