Adds request-response semantics to a socket by encapsulating it with an input-output stream pair. More...
#import <CFStreamPair.h>
Instance Methods | |
(id) | - initWithRequestStream:responseStream: |
(id) | - initWithSocketNativeHandle: |
(void) | - open |
Opens the request and response streams, scheduling them for service within the current run loop. More... | |
(void) | - close |
Reverses the opening. More... | |
(NSData *) | - receiveAvailableBytes |
Destructively receives bytes from the request buffer. More... | |
(NSString *) | - receiveLineUsingEncoding: |
Special convenience method for receiving lines of text from the request stream based on a given string encoding. More... | |
(void) | - sendBytes: |
(void) | - hasBytesAvailable |
(void) | - hasSpaceAvailable |
(void) | - sendBytes |
(void) | - handleRequestEvent: |
(void) | - handleResponseEvent: |
(id) | - init [implementation] |
(void) | - dealloc [implementation] |
(void) | - stream:handleEvent: [implementation] |
Properties | |
id< CFStreamPairDelegate > | delegate |
NSInputStream * | requestStream |
NSOutputStream * | responseStream |
NSMutableData * | requestBuffer [implementation] |
NSMutableData * | responseBuffer [implementation] |
Adds request-response semantics to a socket by encapsulating it with an input-output stream pair.
For TCP connections, the request input stream corresponds to the request; receive the request bytes from the request input, send the response to the response output stream.
Definition at line 47 of file CFStreamPair.h.
- (void) close |
Reverses the opening.
Closes the request and response streams, removes them from the current run loop. This assumes that you send -close
from the same thread as you sent the original -open
.
Definition at line 124 of file CFStreamPair.m.
|
implementation |
Definition at line 68 of file CFStreamPair.m.
- (void) handleRequestEvent: | (NSStreamEvent) | eventCode |
Definition at line 217 of file CFStreamPair.m.
- (void) handleResponseEvent: | (NSStreamEvent) | eventCode |
Definition at line 267 of file CFStreamPair.m.
- (void) hasBytesAvailable |
Definition at line 185 of file CFStreamPair.m.
- (void) hasSpaceAvailable |
Definition at line 197 of file CFStreamPair.m.
|
implementation |
Definition at line 50 of file CFStreamPair.m.
- (id) initWithRequestStream: | (NSInputStream *) | requestStream | |
responseStream: | (NSOutputStream *) | responseStream | |
Definition at line 74 of file CFStreamPair.m.
- (id) initWithSocketNativeHandle: | (NSSocketNativeHandle) | socketNativeHandle |
Definition at line 85 of file CFStreamPair.m.
- (void) open |
Opens the request and response streams, scheduling them for service within the current run loop.
You cannot reopen the streams.
This method assumes that you have not already delegated, scheduled or opened the underlying request-response stream pair.
Definition at line 113 of file CFStreamPair.m.
- (NSData *) receiveAvailableBytes |
Destructively receives bytes from the request buffer.
Definition at line 138 of file CFStreamPair.m.
- (NSString *) receiveLineUsingEncoding: | (NSStringEncoding) | encoding |
Special convenience method for receiving lines of text from the request stream based on a given string encoding.
The result includes any line termination characters. There could be more than one termination character at the end of the line since some line termination sequences span multiple characters.
nil
if the request buffer does not yet contain a complete line. Try again later. Definition at line 145 of file CFStreamPair.m.
- (void) sendBytes |
Definition at line 207 of file CFStreamPair.m.
- (void) sendBytes: | (NSData *) | outputBytes |
Definition at line 170 of file CFStreamPair.m.
|
implementation |
Definition at line 290 of file CFStreamPair.m.
|
readwriteatomicweak |
Definition at line 49 of file CFStreamPair.h.
|
readwriteatomicstrongimplementation |
Definition at line 32 of file CFStreamPair.m.
|
readwriteatomicstrong |
Definition at line 50 of file CFStreamPair.h.
|
readwriteatomicstrongimplementation |
Definition at line 33 of file CFStreamPair.m.
|
readwriteatomicstrong |
Definition at line 51 of file CFStreamPair.h.