NSFileHandle

NSFileHandle

Post by drma » Mon, 11 Aug 2003 02:02:22



Does anyone have any sample code on controlling a /dev/ device with
NSFileHandle? The three books I have only mention its existence and I can't
find anything on Google that has example code.

Thanks,
Matthew

 
 
 

NSFileHandle

Post by Tom Harringto » Mon, 11 Aug 2003 03:30:09




> Does anyone have any sample code on controlling a /dev/ device with
> NSFileHandle? The three books I have only mention its existence and I can't
> find anything on Google that has example code.

NSFileHandle is essentially an Objective-C style convenience serving
more or less the same purpose as lower-level Unix-style functions like
open(), read(), etc.  If you want to work with something in /dev/, it
should work more or less as you'd handle the device in standard Unix.  
If the real problem is that you don't know how to deal with /dev/ at
all, your question's about Unix and not Objective C.  A good Unix
programming reference would be the place to start.

It might be possible to give more detailed help if you posted more
detail about what you're really trying to do.

--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 1.4:  Best cleanup yet, gets files other tools miss.
See http://www.atomicbird.com/

 
 
 

1. NSFileHandle and irc

I am working on learning objective-c.
I have decided to start with some socket work, namely irc.
So far, I can connect, and send all the info needed to join a channel on
a server and say something.
But, I am not able to figure out a good loop with tha available methods
in NSFileHandle, the class I am using.  I have thought to use
readInBackgroundAndNotify, but not sure how that would work.
this is what I tried, but it dumped.

-run
{
    NSData *in;
    do{
        in = [irc availableData];
        [self relay:in];
    } while(in != NULL);

relay:(NSData *)data is uncomfirmed, but it doesn't use anything
unusual, or not used already to get to this point.

Should I just forget this and use some other set of classes, or is there
a way to do this?  Anyone know a good way to go about reading from an
irc server?

2. Custom Ringing Answering Machine