Question

When I look at the NSFileHandle API docs, I see there are a lot of networking methods talking about sockets and stuff like that...

At the top, they say:

NSFileHandle objects provide an object-oriented wrapper for accessing open files or communications channels.

What's an "communication channel" here? Are there some practical examples that explain it for someone who's not a networking-ninja?

Was it helpful?

Solution

Basically it's an abstraction letting you access a variety of communications channels using a common interface. It applies to most things with which you send and/or receive bytes of data.

Could be pipe (which is a way of communicating between processes on the same computer); a socket, which is basically the end point of an IP connection; a device such as a piece of hardware with which you can exchange data. All these get abstracted to a sort of file-like IO with read and write instructions.

Using a file handle lets you ignore the underlying detail (netwworking etc.) and just get at the data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top