{{title}}

Status: NO-STATUS

This example shows how you can use standard C library file and socket operation functions in Native Client using a library called nacl_io.

nacl_io provides a virtual filesystem. The filesystem can be "mounted" in a given directory tree. When you perform operations on files in those directories, the mount determines how those operations should be performed.

This example has four mounts by default.

  1. / the root of the filesystem. This is a memory mount, and is non-persistent.
  2. /persistent a persistent storage area. Any data written here can be read back after Chrome is restarted.
  3. /http a mount that can read from a URL. Try reading from /http/index.html.
  4. /dev a mount containing some utility files. /dev/null, /dev/zero, etc.

nacl_io also provides a (currently incomplete) posix socket api. Like the virtual filesystem, it is an abstraction layer on top of ppapi. To use this API, an app must be a packaged app with the appropriate socket permissions specified in the manifest file.


File Operations:

fopen fclose fread fwrite fseek fflush stat
Filename:

Directory Operations:

opendir readdir closedir mkdir rmdir chdir getcwd

Socket Operations:

gethostbyname getaddrinfo connect send recv close

JavaScript Pipe Operations:

Type input while the focus is on this box the send input to the pipe device:

Any output from the pipe will be printed below:


Log: