Lines Matching refs:socket

10 - Connect to the peer device over a socket.
14 …Is and sample code, see [@ohos.bluetooth.socket](../../reference/apis-connectivity-kit/js-apis-blu…
20 | sppListen() | Creates an SPP listening socket for the server. …
21 | sppAccept() | Accepts a connection request from the client over a socket o…
23 | sppCloseServerSocket() | Closes the listening socket of the server. …
24 | sppCloseClientSocket() | Closes the client socket. …
25 | sppWrite() | Sends data to the remote end over the socket. …
32 1. Import the **socket** module.
35 4. Creates a server socket. If the operation is successful, **serverId** is returned.
36 5. Create a communication channel between the server socket and the client socket. If the operation…
39 8. Close the server socket.
40 9. Close the client socket.
44 import { socket } from '@kit.ConnectivityKit';
47 // Create a server listening socket. serverId is returned if the socket is created.
49 let sppOption: socket.SppOptions = {
54 socket.sppListen('server1', sppOption, (code, serverSocketID) => {
64 …// Establish a connection between the server socket and client socket. If the connection is succes…
66 socket.sppAccept(serverNumber, (code, clientSocketID) => {
83 socket.sppWrite(clientNumber, array.buffer);
87 socket.on('sppRead', clientNumber, (dataBuffer: ArrayBuffer) => {
97 socket.off('sppRead', clientNumber, (dataBuffer: ArrayBuffer) => {
106 // Close the server socket.
107 socket.sppCloseServerSocket(serverNumber);
110 // Close the client socket.
111 socket.sppCloseClientSocket(clientNumber);
118 1. Import the **socket** module.
126 import { socket } from '@kit.ConnectivityKit';
133 socket.sppConnect(deviceId, {