ios - NSInputStream and NSOutputStream problems -
i have 2 nsinputstream
, nsoutputstream
between devices connected each other via network. when write in output stream
, info written until nsstreameventendencountered
event occurs. close output stream on other side (input stream
) nsstreameventendencountered
event never occurs, until exit view controller of output stream
. so: 1. why not nsstreameventendencountered
event occurs @ input stream
after the same occurred @ output stream
? (the output stream closed in event) 2. understanding that, 1 time open nsoutputstream
, can write info once. opening output stream
1 time again after nsstreameventendencountered
event (for illustration write new on event) not possible, right ????
i need more info connection , how you're sending info allow me seek , reply questions:
1.
you're not encountering end of inputstream
because never started reading it. outputstream
finished writing because encountered end, said.
imagine jacob (your outputstream
) delivering envelope (your data) friend's house. jacob puts envelope on friend's doormat , walks own house. at point jacob's work done tells himself he's done (in case outputstream
signals nsstreameventendencountered
).
jacob's friend george (your inputstream
) see envelope or not, nevertheless never looks in it. so unless george takes envelope , looks within it, never tell himself finished looking @ (in case inputstream
never signals nsstreameventendencountered
).
2.
this depends on how plan utilize outputstream
. if plan send info multiple times same device, why not leave outputstream
open? can write info long socket open , there space available. when close outputstream
need reopen however.
ios nsstream nsinputstream nsoutputstream
No comments:
Post a Comment