Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 2.43 KB

index.md

File metadata and controls

60 lines (39 loc) · 2.43 KB

org.apache.cordova.labs.tcpsocket

This plugin is used to run sockets

Objects

  • navigator.TCPSocket

Methods

navigator.TCPSocket.open

navigator.TCPSocket.open(host, port, successCallback, errorCallback, options)
  • host is a string representing the hostname of the server to connect to (it can also be its raw IP address).
  • port is a umber representing the TCP port to be used by the socket (some protocols have a standard port, for example 80 for HTTP, 447 for SSL, 25 for SMTP, etc. Port numbers beyond 1024 are not assigned to any specific protocol and can be used for any purpose.)
  • options is an object containing
    • useSecureTransport (Boolean) false (default)
    • binaryType (String) "string" (default) or "arrayBuffer"

an instantiation of a new TCPSocket object is returned in success callback

Firefox OS quirks

Only certified apps can use a port below 1024.

navigator.TCPSocket.listen

navigator.TCPSocket.listen(port, successCallback, errorCallback, options, queueLimit)
  • port is a number representing the TCP port to be used to listen for connections.
  • options is an optional object expecting a property called binaryType which is a string that can have two possible values: string and arraybuffer. If the value is arraybuffer then the TCPSocket.send() will use ArrayBuffers and the data received from the remote connection will also be available in that format.
  • queueLimit is a number representing the maximum lenght that the pending connections queue can grow.

an instantiation of a new TCPSocket object is returned in success callback

Firefox OS quirks

Only certified apps can use a port below 1024.