TCPSocket
Description#
The TCPSocket interface provides access to a raw TCP socket.
The main entry point for this API is the navigator.mozTCPSocket property which is a TCPSocket object.
Note: Only certified apps can accept incoming connections on a port below 1024.
API overview#
Properties#
TCPSocket.host Read only
A string representing the host name of the server the socket is connected to.
TCPSocket.port Read only
A number representing the port the socket is connected to.
TCPSocket.ssl Read only
A boolean indicating whether the socket is encrypted with SSL (true) or not (false).
TCPSocket.bufferedAmount Read only
The number of bytes of not-yet-sent data in the socket buffered.
TCPSocket.binaryType Read only
The type of data used. Possible value is arraybuffer or string.
TCPSocket.readyState Read only
The socket state. Possible value is connecting, open, closing, or closed.
Events handler#
TCPSocket.onopen
A handler for the open event. After this event, the socket is ready to send and receive data.
TCPSocket.ondrain
A handler for the drain event. This event is triggered each time the buffer of data is flushed.
TCPSocket.onerror
A handler for the error event.
TCPSocket.ondata
A handler for the data event. This event is triggered each time data has been received.
TCPSocket.onclose
A handler for the close event.
Methods#
TCPSocket.close()
Closes the connection.
TCPSocket.open(host, port [, options])
Returns a new TCPSocket object connected to the given host at the given port.
TCPSocket.listen(port [, options [, backlog]])
Returns a new TCPServerSocket object listening at the given port.
TCPSocket.resume()
Resumes the data events.
TCPSocket.send(data)
Buffers data to be sent across the network.
TCPSocket.suspend()
Pauses the data events.
TCPSocket.upgradeToSecure()
Enables secure on channel.