• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. TCPSocket
  6. TCPSocket.onerror

TCPSocket.onerror

In This Article
  1. Summary
  2. Syntax
    1. TCPSocketEvent
  3. Specification
  4. See also

This API is available on Firefox OS for privileged or certified applications only.

Summary

The onerror property is used to specify an event handler to receive error events. Those events are triggered each time an error occurs.

Note: If an error occurs before the connection has been opened, the error was connection refused,
and the close event will not be triggered. If an error occurs after the connection has been opened, the connection was lost, and the close event will be triggered after the error event.

Syntax

instanceOfTCPSocket.onerror = funcRef

Where funcRef is a function to be called when the error event occurs.

This callback function will get a TCPSocketEvent object as its first parameter.

TCPSocketEvent

Such events are simple JavaScript objects with the following properties:

target
The TCPSocket object which fired the event.
type
A string defining the type of the event. Its value can be one of the following: open, error, data, drain, or close.
data
The data related to the event, if any.

In case of error, the data property is a string containing the description of the error.

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

  • TCPSocket
  • TCP Socket

Document Tags and Contributors

Tags: 
  • API
  • B2G
  • Firefox OS
  • Non Standard
  • Property
  • Reference
  • Référence
  • TCP Socket
 Contributors to this page: chrisdavidmills, teoli, MHasan, kscarfone, Jeremie
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:07:49 AM
See also
  1. TCP Socket API
  2. Archive
  3. Events
    1. data
    2. drain
    3. connect
    4. error
  4. Related pages for TCP Socket API
    1. TCPServerSocket
    2. TCPSocket