Sun SPOT API
Green Release  


com.sun.squawk.io.mailboxes
Class ServerChannel

java.lang.Object
  extended by com.sun.squawk.io.mailboxes.ServerChannel

public class ServerChannel
extends Object

Given that a Channel is a one-to-one connection between two isolates, a ServerChannel provides a factory to create new Channels by name. It is similar to how network sockets can use a port umber to accept a number of client connections. A server can use a the accept method to accept new client connections, which will return a new Channel that the server can use to talk to the client. A server may choose to service each Channel in a seperate thread.


Method Summary
 Channel accept()
          Wait for a client to open a connection, then create an anonymous local mailbox to use or further communication.
 void close()
          Unregisters this ServerChannel and it's MailBox.
static ServerChannel create(String name)
          Creates a new ServerChannel and new Mailbox with the given name and registers it with the system.
 String getName()
          Get the name that this ServerChannel was registered under.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static ServerChannel create(String name)
                            throws MailboxInUseException
Creates a new ServerChannel and new Mailbox with the given name and registers it with the system. When a client does a lookup on this mailbox, the ServerChannel creates a new private mailbox, and tells the client to use the private mailbox. Given a ServerChannel, a server may call accept(), waiting for clients to connect to it. Accept will return with a new Channel (and private mailbox) to handle communication with this client.

Parameters:
name - the name that this Mailbox can be looked up under.
handler - the class used to manage clients opening and closing new logical connections to the new Mailbox.
Returns:
the new ServerChannel
Throws:
MailboxInUseException - if there is already a mailbox registered under the name name.

getName

public String getName()
Get the name that this ServerChannel was registered under.

Returns:
the name

accept

public Channel accept()
Wait for a client to open a connection, then create an anonymous local mailbox to use or further communication.

Returns:
a new Channel to the client

close

public void close()
Unregisters this ServerChannel and it's MailBox. Should this close existing Channels that came from this channel?


Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.