|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
public interface P2PConnectionLess
This interface exposes the methods for the P2P connectionless. Use
P2PManager.createP2PConnectionLess(java.lang.String, byte) to create a new instance of P2P
connectionless.
| Method Summary | |
|---|---|
void |
cancel()
Cancels every pending operation. |
void |
close()
Closes a pending connectionLess. |
byte |
getLocalSap()
Retrieves the local Service Access Point value. |
boolean |
ready()
Determines if there is a data that can be receive via a call to recvFrom(). |
int |
recvFrom(byte[] data)
Reads some number of bytes from the P2P connectionless and stores them into the buffer array data. |
int |
recvFrom(byte[] data,
int off,
int len)
Reads up to len bytes of data from the P2P connection
into an array of bytes. |
void |
sendTo(byte sap,
byte[] data)
Sends data.length bytes from the specified byte array through
a connectionless transport. |
void |
sendTo(byte sap,
byte[] data,
int off,
int len)
Sends len bytes from the specified byte array
starting at offset off through a connectionless transport. |
| Method Detail |
|---|
byte getLocalSap()
throws IOException,
NfcException
IOException - if the connection is not connected.
NfcException - if a NFC error occurred.
void sendTo(byte sap,
byte[] data)
throws IOException
data.length bytes from the specified byte array through
a connectionless transport. The general contract for sendTo(data)
is that it should have exactly the same effect as the call
sendTo(data, 0, data.length).
sap - the remote SAP value. Valid range is 2..63.data - the buffer containing the data to be sent.
IllegalStateException - if the connection is not open or if another
write operation is pending.
IllegalArgumentException - if the data buffer is null.
IOException - if an error occurs during the communication with the
peer device, or if cancel() is called before the
write operation is completed, or if the peer device closed
the connection before receiving the data.
void sendTo(byte sap,
byte[] data,
int off,
int len)
throws IOException
len bytes from the specified byte array
starting at offset off through a connectionless transport.
If data is null, a
NullPointerException is thrown.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, then an IndexOutOfBoundsException is thrown.
sap - the remote SAP value. Valid range is 2..63.data - the buffer containing the data to be sent.off - the start offset in byte of the data in the buffer.len - the number of bytes to write.
IllegalStateException - if the connection is not open or if another
write operation is pending.
IllegalArgumentException - if the data buffer is null
or if offset or length are negative.
IndexOutOfBoundsException - if the off or
len are outside of the data buffer.
IOException - if an error occurs during the communication with the
peer device, or if cancel() is called before the
write operation is completed, or if the peer device closed
the connection before receiving the data.
int recvFrom(byte[] data)
throws IOException
data. The number of bytes actually read is
returned as an integer.
The remote Service Access Point (SAP) is be stored in a byte at the end of the data buffer array. The length returned by recvFrom() does not include this byte.
This method blocks until input data is available, or an exception is thrown.
-1 if there is no more data.
IllegalStateException - if the connection is not open or if another
read operation is pending.
IllegalArgumentException - if the data buffer is null.
IOException - if an error occurs during the communication with the
peer device or if cancel() is called before the read
operation is completed.
int recvFrom(byte[] data,
int off,
int len)
throws IOException
len bytes of data from the P2P connection
into an array of bytes. An attempt is made to read as many as
len bytes, but a smaller number may be read, possibly
zero. The number of bytes actually read is returned as an integer.
The remote Service Access Point (SAP) is be stored in a byte at the end of the data buffer array. The length returned by recvFrom() does not include this byte.
This method blocks until input data is available, or an exception is thrown.
If data is null, a
NullPointerException is thrown.
If off is negative, or len is negative, or
off+len is greater than the length of the array
b, then an IndexOutOfBoundsException is
thrown.
If len is zero, then no bytes are read and
0 is returned; otherwise, there is an attempt to read at
least one byte. If no byte is available , the value -1 is returned;
otherwise, at least one byte is read and stored into data.
-1 if there is no more data.
IllegalStateException - if the connection is not open or if another
read operation is pending.
IllegalArgumentException - if the data buffer is null
or if offset or length are negative.
IndexOutOfBoundsException - if the off or
len are outside of the data buffer.
IOException - if an error occurs during the communication with the
peer device or if cancel() is called before the read
operation is completed.
boolean ready()
throws IOException
recvFrom().
If true, a call to recvFrom() will not block the application.
IOException - if connection to the target is lost or it has been closed.void cancel()
void close()
throws IOException
IOException - if the connectionLess is broken.
|
Copyright © 2010-2011 Inside Secure |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||