What's new? | Help | Directory | Sign in
Google
                
Search
for
Updated Aug 18, 2008 by soubok
Labels: doc
jsio  
jsio module

- source - main -

jsio module

This module is based on Netscape Portable Runtime (NSPR) that provides a platform-neutral API for system level and libc like functions. NSPR API is used in the Mozilla client, many of Netscape/AOL/iPlanet's and other software offerings.

Static functions

  • WaitSemaphore( semaphoreName )
  • Tests the value of the semaphore. If the value of the semaphore is > 0, the value of the semaphore is decremented and the function returns. If the value of the semaphore is 0, the function blocks until the value becomes > 0, then the semaphore is decremented and the function returns.
    note:
    The "test and decrement" operation is performed atomically.

Static properties


jsio::Descriptor class

- src - top -

Methods

Properties

Static functions

Constants

Native Interface


jsio::Directory class

- src - top -

This class manages directory I/O Functions.

Methods

Properties

Static functions

Constants

Example

var dir = new Directory( 'c:/tmp' );
dir.Open();
for ( var entry; ( entry = dir.Read() ); ) {

   var file = new File(dir.name+'/'+entry);
   Print( entry + ' ('+ file.info.type +')', '\n');
}

Example

function RecursiveDir(path) {
   var testList = [];
   (function(path) {
      var dir = new Directory(path);
      dir.Open();
      for ( var entry; ( entry = dir.Read(Directory.SKIP_BOTH) ); ) {
         
         var file = new File(dir.name+'/'+entry);
         switch ( file.info.type ) {
            case File.FILE_DIRECTORY:
               arguments.callee(file.name);
               break;
            case File.FILE_FILE:
               testList.push(file.name);
               break;
         }
      }
      dir.Close();
   })(path);
   return testList;
}

Print( RecursiveDir('jshost').join('\n') );

jsio::File class jsio::Descriptor

- src - top -

  • constructor( fileName )

Methods

Properties

Static properties

Constants

Native Interface

Example

LoadModule('jsstd');
LoadModule('jsio');

try {

   var file = new File('file_test.txt');
   if ( file.exist ) {
      file.Open( File.RDONLY );
      Print( 'file content:\n' + file.Read() );
      file.Close();
   }

} catch ( ex if ex instanceof IoError ) {

   Print( 'IOError: ' + ex.text, '\n' );
} catch( ex ) {

   throw ex;
}

jsio::MemoryMapped class

- src - top -

Properties

Native Interface

Example

var f = new File('directory.cpp');
f.Open("r");
var m = new MemoryMapped(f);
Print(m);

jsio::Pipe class

- src - top -


jsio::Semaphore class

- src - top -


jsio::SharedMemory class

- src - top -

This class manages shared memory between two or more process.

  • constructor( name, size [, mode] )
  • Creates a named shared memory area of size bytes using mode linux-like rights.

Methods

Properties

Native Interface

Exemple

LoadModule('jsstd');
LoadModule('jsio');

var mem1 = new SharedMemory( 'mytest', 100 );
mem1.Write('foo');

var mem2 = new SharedMemory( 'mytest', 100 );
Print( mem2.Read(3), '\n' );

jsio::Socket class jsio::Descriptor

- src - top -

Socket class is used to create a non-blocking TCP socket.

  • constructor( = Socket.TCP )
  • Type can be Socket.TCP or Socket.UDP.

Methods

Properties

  • boolean reuseAddr
  • Allow local address reuse.

  • boolean keepAlive
  • Keep connections alive.

  • integer recvBufferSize
  • Receive buffer size.
  • integer sendBufferSize
  • Send buffer size.
  • integer maxSegment
  • Maximum segment size.
  • boolean nonblocking
  • Non-blocking (network) I/O.
  • boolean broadcast
  • Enable broadcast.
  • boolean multicastLoopback
  • IP multicast loopback.

  • string peerName
  • Get name of the connected peer. Return the network address for the connected peer socket.
  • integer peerPort
  • Get port of the connected peer. Return the port for the connected peer socket.
  • string sockName
  • Get socket name. Return the network address for this socket.
  • integer sockPort
  • Get socket port. Return the port for this socket.

Static functions

Constants

Native Interface


jsio::IoError class

- src - top -

You cannot construct this class. Its aim is to throw as an exception on any NSPR runtime error.

Properties


- top - main - source - QA -


Sign in to add a comment