Questions tagged [nsstream]

NSStream is an abstract class for objects representing streams.

NSStream is an abstract class for objects representing streams. Its interface is common to all Cocoa stream classes, including its concrete subclasses NSInputStream and NSOutputStream.

NSStream objects provide an easy way to read and write data to and from a variety of media in a device-independent way.

For more information : NSStream Class Reference

327 questions
0
votes
2 answers

Detect how many bytes can be written to NSOutputStream

Basic problem I'm try to implement: I have two streams. NSInputStream and NSOutputStream. Now I want to take some data from input process them (add some frames encode them and so on) and pass to output. So far so good. Actual problem Problem is that…
Marek R
  • 32,568
  • 6
  • 55
  • 140
0
votes
0 answers

How can a client know that Server is sending some X bytes?

let bufferSize = 4096 var buffer = Array(count: bufferSize, repeatedValue: 0) var message = "" while inputStream.hasBytesAvailable { let len = inputStream.read(&buffer,…
Srikanth Adavalli
  • 665
  • 1
  • 10
  • 25
0
votes
1 answer

How can i wait till i receive all the tcp packets to Client from Server using NSStream

case NSStreamEvent.EndEncountered: BBLogMsg("End Encountered") guard let inputStream = self.inputStream else { return BBLogError("no input stream") } let bufferSize = 4096 …
Srikanth Adavalli
  • 665
  • 1
  • 10
  • 25
0
votes
1 answer

Setting TCP_NODELAY for NSOutputStream in Swift

This answer and this answer both show how to set TCP_NODELAY for NSOutputStream in Objective-C. I need some help on getting this to work in Swift, and I believe that it's probably just a mistake I'm making with the API. This is the Objective-C…
Hundley
  • 3,167
  • 3
  • 23
  • 45
0
votes
0 answers

NSStream TCP Client Socket not working reliably

I am trying to build an app that communicates with a TCP server on my network. The code I am using is this: let addr = "192.168.1.104" let port = 101010 var inp: NSInputStream? var out: NSOutputStream? @IBAction func Connect_Button(sender:…
Rs2845
  • 53
  • 1
  • 6
0
votes
3 answers

How do you correctly work with NSStreams (no blocking, read to the end of the data, and message retrying)?

I'm trying to work with NSInputStream and NSOutputStream but it's causing a lot of pain. I have two devices that communicate Json. Some of the data can be very long so NSOutputStreamsends splits it up in multiple packets. I need receiving not to…
Daniel Ryan
  • 6,976
  • 5
  • 45
  • 62
0
votes
1 answer

Performing TCP/IP network I/O in Swift

I'm writing a Swift application under OS X that needs to do TCP/IP port-level network I/O (optionally with SSL/TLS). I've done a lot of searching and it looks like NSStream is the way to go for this. However, the class reference for NSStream says…
0
votes
0 answers

NSStream connection to server issues with data being sent

I am trying to communicate with a java server using NSStream however I can't determine how to limit the data sent by this code to a single "hello" and also prevent it from lopping off the initial 2 characters. NSInputStream…
0
votes
1 answer

Error calling segue in Nsstream

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'backSegue'' *** First throw call stack: (0x1842c0f5c 0x198eb3f80 0x189b7b774…
0
votes
1 answer

Reading large files from NSInputstream is not working in ios

I am trying to read large Image file more than 300KB from NSInputStream. But i'm getting only upto 300KB. Other data are missing. Could you please help me if you know. i'm waiting for your valuable answer. I mentioned my code below : Call this…
vishnu
  • 13
  • 2
0
votes
2 answers

Swift NSStream() SSL - Ask User to Confirm

I am writing a TCPClient class for communicating with a SSL/TLS TCP socket server in Swift, and the server is automatically generating self-signed certificates when it doesn't find or isn't able to successfully use a valid certificate. These…
Hank Brekke
  • 2,024
  • 2
  • 24
  • 33
0
votes
2 answers

NSInputStream not receive all data

Error appear when i received data from server (data just string). for example server sent data (15000bytes) my iPhone received data (7878bytes) so I try to searching and i know while method is answer. but I can't apply my code.. I guess…
Gimin Choi
  • 13
  • 2
0
votes
1 answer

setting CFStream property failing

I'm trying to set up TLS connection with SNI. Problem is that the first property setting call returns 1 indicating that it was accepted. The following two return 0, which means they didn't go through. What could be the reasoning be? At some point I…
Kelo
  • 453
  • 1
  • 3
  • 17
0
votes
1 answer

Should a Bluetooth-communicating NSStream require a separate thread?

Using ExternalAccessory to talk to a Bluetooth device, I'm using the input and output NSStreams supplied by EASession to send messages to it. In Apple's EADemo example, it schedules both streams to the main thread's run loop. However, I have noticed…
Matoe
  • 2,742
  • 6
  • 33
  • 52
0
votes
1 answer

IOS Stream Socket

I am working about socket using Stream I used this code to connect to my server: - (void)initNetworkCommunication { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"host",…