|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.whispercomm.manes.client.maclib.ManesInterface
public class ManesInterface
This class represents an interface for sending and receiving one-hop broadcast packets via the MANES ad hoc network emulation system.
ManesInterface
depends on
ManesService
, which must be installed.
ManesService
Field Summary | |
---|---|
static int |
MANES_MTU
The maximum allowable size in bytes of an outgoing packet. |
Constructor Summary | |
---|---|
ManesInterface(int appId,
Context callerContext)
Constructs a new ManesInterface object to send and receive
packets with the specified application id. |
Method Summary | |
---|---|
byte[] |
receive(long timeout)
Retrieves an incoming packet, blocking until one is available, up to the specified timeout. |
void |
send(byte[] sendBuff)
Broadcasts the given packet to this device's one-hop neighborhood. |
void |
unregister()
Closes the interface, unbinding from ManesService . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MANES_MTU
Constructor Detail |
---|
public ManesInterface(int appId, Context callerContext) throws RemoteException
ManesInterface
object to send and receive
packets with the specified application id.
The application id is used to filter incoming packets to the appropriate application and thus must consistent across all instances of the application and globally unique to the application. To ensure uniqueness, it should be registered in the MANES application id registry. Application ids 253, 254, and 255 are available for testing and experimentation.
The constructor binds the specified context to the
ManesService
background service. When finished, the
ManesInterface
instance must be unbound from the service by
calling unregister
.
appId
- the registered identifier for this application.callerContext
- the context used to bind to ManesService
.
RemoteException
ManesIllegalAppIdException
- if an illegal (i.e., negative) application id is supplied.Method Detail |
---|
public void send(byte[] sendBuff) throws ManesFrameTooLargeException, IOException
The packet size must not exceed MANES_MTU
.
sendBuff
- the packet to be sent.
ManesFrameTooLargeException
- if the packet size exceeds MANES_MTU
.
IOException
- if the send fails on the local device. This exception is not
guaranteed to be thrown.public byte[] receive(long timeout) throws IOException
timeout
- the maximum time in milliseconds to block waiting for an
incoming packet.
null
if the timeout occurs.
IOExeception
- if a local error prevents listening for incoming packets.
This exception is not guaranteed to be thrown.
IOException
public void unregister()
ManesService
.
The method must be called when an application is finished with the interface, e.g., before exiting.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |