TCPSocket.onopen

  • Revision slug: Web/API/TCPSocket.onopen
  • Revision title: TCPSocket.onopen
  • Revision id: 429431
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

{{ domref() }}

{{ non-standard_header() }}

{{ B2GOnlyHeader2('privileged') }}

Summary

The onopen property is used to specify an event handler to receive {{event("open")}} events. Those events are triggered each time the connection to the server has been established.

Syntax

instanceOfTCPSocket.onopen = funcRef

Where funcRef is a function to be called when the {{event("open")}} event occurs.

This callback function will get a {{Anch("TCPSocketEvent")}} objet as it's first parameters.

TCPSocketEvent

Such events are simple JavaScript objects with the following properties:

target
The {{domxref("TCPSocket")}} object which fired the event.
type
A string defining the type of the event. It's value can be one of the following: open, error, data, drain or close.
data
The data related to the event, if any.

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

Revision Source

<p>{{ domref() }}</p>
<p>{{ non-standard_header() }}</p>
<p>{{ B2GOnlyHeader2('privileged') }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>onopen</code> property is used to specify an event handler to receive {{event("open")}} events. Those events are triggered each time the connection to the server has been established.</p>
<h2 id="Syntax">Syntax</h2>
<pre>
<em>instanceOfTCPSocket</em>.onopen = <em>funcRef</em></pre>
<p>Where <code><em>funcRef</em></code> is a function to be called when the {{event("open")}} event occurs.</p>
<p>This callback function will get a {{Anch("TCPSocketEvent")}} objet as it's first parameters.</p>
<h3 id="TCPSocketEvent">TCPSocketEvent</h3>
<p>Such events are simple JavaScript objects with the following properties:</p>
<dl>
  <dt>
    <code>target</code></dt>
  <dd>
    The {{domxref("TCPSocket")}} object which fired the event.</dd>
  <dt>
    <code>type</code></dt>
  <dd>
    A string defining the type of the event. It's value can be one of the following: <code>open</code>, <code>error</code>, <code>data</code>, <code>drain</code> or <code>close</code>.</dd>
  <dt>
    <code>data</code></dt>
  <dd>
    The data related to the event, if any.</dd>
</dl>
<h2 id="Specification">Specification</h2>
<p>Not part of any specification yet; however, this API is discussed at W3C as part of the <a class="external" href="http://www.w3.org/2012/sysapps/" rel="external" title="http://www.w3.org/2012/sysapps/">System Applications Working Group</a> under the <a href="http://www.w3.org/2012/sysapps/raw-sockets/" title="http://www.w3.org/2012/sysapps/raw-sockets/">Raw Sockets</a> proposal.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("TCPSocket")}}</li>
  <li><a href="/en-US/docs/WebAPI/TCP_Socket" title="/en-US/docs/WebAPI/TCP_Socket">TCP Socket</a></li>
</ul>
Revert to this revision