This API is available on Firefox OS for privileged or certified applications only.
Summary
The open
method is used to open a TCP connection to a given server on a given port.
Syntax
var instanceOfTCPSocket = navigator.mozTCPSocket.open(host, port[, options]);
Parameters
- host
- A string representing the host name of the server to connect to.
- port
- A number representing the port to connect to.
- options
-
An object specifying the details of the socket. This object expects one or more of the following properties:
useSecureTransport
: use the value to create an SSL socket. Defaults to false.binaryType
: a string with the valuestring
(default) orarraybuffer
. If the latter is used the argument for thesend()
method must be an ArrayBuffer and the data received from the server will be available as an ArrayBuffer. Otherwise, a string is expected.
Note: In an older verson of the API (supported in Firefox 1.0.1),
useSecureTransport
was calleduseSSL
. You can pass both the older and newer options in if wished, to avoid breaking old versions of Firefox OS. See here for an example.
Returns
It returns a new TCPSocket
object connected to the provided host
on the provided port
.
Example
var socket = navigator.mozTCPSocket.open("www.mozilla.org", 80);
Specification
Not part of any specification yet; however, this API is discussed at W3C as part of the System Applications Working Group under the Raw Sockets proposal.
See also
Document Tags and Contributors
Tags:
Contributors to this page:
chrisdavidmills,
teoli,
mkato,
Andrew Sutherland,
kscarfone,
.vimrc,
Jeremie
Last updated by:
chrisdavidmills,