public class SppServerSocket extends Object
The SPP socket interface has two roles:
SppServerSocket and SppClientSocket. To create an SppServerSocket,
use DataListenSocket to create a listening SPP server.
When a connection is accepted by SppServerSocket, it returns a new SppClientSocket
for data transmission.
The most common transmission channel of SPP is RFCOMM, which is established by Bluetooth BR/EDR.
To create an RFCOMM SPP in traditional Bluetooth, use
DataListenSocket#dataListenRfcomm or DataListenSocket#dataListenInsecureRfcomm. The server listens for a new BR/EDR connection.
After an SppClientSocket instance is created, call accept() to allow for a new remote connection.
An SppClientSocket will be returned, from which you can obtain InputStream or
OutputStream
to read and write data.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
SppClientSocket |
accept() |
Waits for a remote device to connect to the
SppServerSocket. |
void |
close() |
Disables an
SppServerSocket and releases related resources. |
public SppClientSocket accept() throws IOException
SppServerSocket.
This method can be used to wait for a new connection to the SppServerSocket.
If the remote device uses the connection mode in DataListenSocket,
an SppClientSocket is returned, which can be used to read data from and write data into streams.
SppClientSocket, which can be used to obtain the input and output streams.IOException - Throws this exception if this call was aborted.public void close()
throws IOException
SppServerSocket and releases related resources.IOException - Throws this exception if the SppServerSocket fails to be disabled.