edu.rutgers.winlab.jmfapi
Class JMFAPI

java.lang.Object
  extended by edu.rutgers.winlab.jmfapi.JMFAPI

public class JMFAPI
extends java.lang.Object

Java API used to interface with MobilityFirst's stack prototype


Constructor Summary
JMFAPI()
          MobilityFirst socket object creation.
 
Method Summary
 boolean isOpen()
          Check if the the stack is open (done locally, no connection to stack).
 void jmfattach(GUID guid)
          Add GUID reachability for the specified GUIDs.
 void jmfattach(GUID[] GUIDs)
          Add GUID reachability for the specified GUIDs.
 void jmfclose()
          Close the socket connection with the stack.
 void jmfdetach(GUID guid)
          Remove GUID reachability for the specified GUID.
 void jmfdetach(GUID[] GUIDs)
          Remove GUID reachability for the specified GUIDs.
 void jmfopen(java.lang.String profile)
          Open the socket connection with the stack
 void jmfopen(java.lang.String profile, GUID guid)
          Open the socket connection with the stack
 void jmfopen(java.lang.String profile, MFFlag opts)
          Open the socket connection with the stack
 void jmfopen(java.lang.String profile, MFFlag opts, GUID guid)
          Open the socket connection with the stack
 int jmfrecv_blk(GUID sGUID, byte[] data, int size)
          Tries to receive the last message received.
 int jmfrecv_blk(GUID sGUID, byte[] data, int size, GUID[] src_GUID)
          Tries to receive the last message received.
 int jmfrecv(GUID sGUID, byte[] data, int size)
          Tries to receive the last message received.
 int jmfrecv(GUID sGUID, byte[] data, int size, GUID[] src_GUID)
          Tries to receive the last message received.
 int jmfsend(byte[] data, int size, GUID dst_GUID)
          Send a chunk of data.
 int jmfsend(byte[] data, int size, GUID dst_GUID, MFFlag opts)
          Send a chunk of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMFAPI

public JMFAPI()
MobilityFirst socket object creation. Cannot perform any functionality until open is called.

Method Detail

jmfopen

public void jmfopen(java.lang.String profile)
             throws JMFException
Open the socket connection with the stack

Parameters:
profile - At the moment contains the string representing the destination GUID
Throws:
JMFException - if an error occurs during the open operation. Usually is due to an error at the API level and in that case contains the errno value

jmfopen

public void jmfopen(java.lang.String profile,
                    MFFlag opts)
             throws JMFException
Open the socket connection with the stack

Parameters:
profile - At the moment contains the string representing the destination GUID
opts - Options parameter; can NOT be null
Throws:
JMFException - if an error occurs during the open operation. Usually is due to an error at the API level and in that case contains the errno value

jmfopen

public void jmfopen(java.lang.String profile,
                    GUID guid)
             throws JMFException
Open the socket connection with the stack

Parameters:
profile - At the moment contains the string representing the destination GUID
guid - Contains the source GUID
Throws:
JMFException - if an error occurs during the open operation. Usually is due to an error at the API level and in that case contains the errno value

jmfopen

public void jmfopen(java.lang.String profile,
                    MFFlag opts,
                    GUID guid)
             throws JMFException
Open the socket connection with the stack

Parameters:
profile - At the moment contains the string representing the destination GUID
guid - Contains the source GUID
opts - Options parameter; can NOT be null
Throws:
JMFException - if an error occurs during the open operation. Usually is due to an error at the API level and in that case contains the errno value

jmfsend

public int jmfsend(byte[] data,
                   int size,
                   GUID dst_GUID,
                   MFFlag opts)
            throws JMFException
Send a chunk of data. The chunk can not be larger than 1 MB

Parameters:
data - data to be sent
size - size of the chunk
dst_GUID - destination GUID for the packet
opts - Options parameter; can NOT be null
Returns:
returns the number of bytes sent (it should correspond to size)
Throws:
JMFException - if an error occurs during the send operation Usually is due to an error at the API level and in that case contains the errno value

jmfsend

public int jmfsend(byte[] data,
                   int size,
                   GUID dst_GUID)
            throws JMFException
Send a chunk of data. The chunk can not be larger than 1 MB

Parameters:
data - data to be sent
size - size of the chunk
dst_GUID - destination GUID for the packet
Returns:
returns the number of bytes sent (it should correspond to size)
Throws:
JMFException - if an error occurs during the send operation Usually is due to an error at the API level and in that case contains the errno value

jmfrecv

public int jmfrecv(GUID sGUID,
                   byte[] data,
                   int size,
                   GUID[] src_GUID)
            throws JMFException
Tries to receive the last message received. If no message has been received it will return immediately without waiting.

Parameters:
sGUID - GUID of the sender. Is written if not null (as of now only null values are acceptable)
data - buffer to be used for the received data
size - max number of bytes that should be received
src_GUID - set of GUIDs to filter receive
Returns:
the number of bytes written into the buffer, -1 if there was no message to receive.
Throws:
JMFException - if an error occurs during the recv operation Usually is due to an error at the API level and in that case contains the errno value

jmfrecv

public int jmfrecv(GUID sGUID,
                   byte[] data,
                   int size)
            throws JMFException
Tries to receive the last message received. If no message has been received it will return immediately without waiting.

Parameters:
sGUID - GUID of the sender. Is written if not null (as of now only null values are acceptable)
data - buffer to be used for the received data
size - max number of bytes that should be received
Returns:
the number of bytes written into the buffer, -1 if there was no message to receive.
Throws:
JMFException - if an error occurs during the recv operation Usually is due to an error at the API level and in that case contains the errno value

jmfrecv_blk

public int jmfrecv_blk(GUID sGUID,
                       byte[] data,
                       int size,
                       GUID[] src_GUID)
                throws JMFException
Tries to receive the last message received. If no message has been received it blocks until one will be retrieved.

Parameters:
sGUID - GUID of the sender. Is written if not null (as of now only null values are acceptable)
data - buffer to be used for the received data
size - max number of bytes that should be received
src_GUID - set of GUIDs to filter receive
Returns:
the number of bytes written into the buffer.
Throws:
JMFException - if an error occurs during the recv operation Usually is due to an error at the API level and in that case contains the errno value

jmfrecv_blk

public int jmfrecv_blk(GUID sGUID,
                       byte[] data,
                       int size)
                throws JMFException
Tries to receive the last message received. If no message has been received it blocks until one will be retrieved.

Parameters:
sGUID - GUID of the sender. Is written if not null (as of now only null values are acceptable)
data - buffer to be used for the received data
size - max number of bytes that should be received
Returns:
the number of bytes written into the buffer.
Throws:
JMFException - if an error occurs during the recv operation Usually is due to an error at the API level and in that case contains the errno value

jmfattach

public void jmfattach(GUID[] GUIDs)
               throws JMFException
Add GUID reachability for the specified GUIDs.

Parameters:
GUIDs - set of GUIDs to add to socket end point
Throws:
JMFException - if an error occurs during the attach operation Usually happens if the stack was not able to add reachability

jmfattach

public void jmfattach(GUID guid)
               throws JMFException
Add GUID reachability for the specified GUIDs.

Parameters:
guid - GUID to add to socket end point
Throws:
JMFException - if an error occurs during the attach operation Usually happens if the stack was not able to add reachability

jmfdetach

public void jmfdetach(GUID[] GUIDs)
               throws JMFException
Remove GUID reachability for the specified GUIDs.

Parameters:
GUIDs - set of GUIDs to remove to socket end point
Throws:
JMFException - if an error occurs during the detach operation Usually happens if the stack was not able to remove reachability

jmfdetach

public void jmfdetach(GUID guid)
               throws JMFException
Remove GUID reachability for the specified GUID.

Parameters:
guid - GUID to remove to socket end point
Throws:
JMFException - if an error occurs during the detach operation Usually happens if the stack was not able to remove reachability

jmfclose

public void jmfclose()
              throws JMFException
Close the socket connection with the stack.

Throws:
JMFException - if an error occurs during the close operation Usually is due to an error at the API level and in that case contains the errno value

isOpen

public boolean isOpen()
Check if the the stack is open (done locally, no connection to stack).