Created
July 12, 2011 12:41
-
-
Save beelsebob/1077898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)connect | |
{ | |
CFReadStreamRef readStream; | |
CFWriteStreamRef writeStream; | |
CFStreamCreatePairWithSocketToHost(NULL, | |
SERVER, | |
PORT, | |
&readStream, | |
&writeStream); | |
[self setInputStream:(NSInputStream *)readStream]; | |
[self setOutputStream:(NSOutputStream *)writeStream]; | |
CFRelease(readStream); | |
CFRelease(writeStream); | |
hasConnected = NO; | |
[[self inputStream] setDelegate:self]; | |
[[self outputStream] setDelegate:self]; | |
NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; | |
[[self inputStream] scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; | |
[[self outputStream] scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; | |
[[self inputStream] open]; | |
[[self outputStream] open]; | |
} | |
- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode | |
{ | |
switch (eventCode) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment