User Tools

Site Tools


en:code:data:tcp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
code:data:tcp [2011/01/27 20:32] jmgren:code:data:tcp [2021/02/13 11:23] (current) – external edit 127.0.0.1
Line 18: Line 18:
     * onReadyRead - ([[#onReadyRead|onReadyRead]]) called when the object is ready to read data sent from the server     * onReadyRead - ([[#onReadyRead|onReadyRead]]) called when the object is ready to read data sent from the server
     * onBytesWritten - ([[#onBytesWritten|onBytesWritten]]) called when the object has finished writing data to the server     * onBytesWritten - ([[#onBytesWritten|onBytesWritten]]) called when the object has finished writing data to the server
 +    * onError - ([[#onError|onError]]) called when an error has occured
  
 === Example === === Example ===
Line 24: Line 25:
 </code> </code>
 <code javascript> <code javascript>
-var myObject = new Sql({+var myObject = new Tcp({
  onConnected: function()  onConnected: function()
  {  {
- Console.print("Connected !");+ Console.print("Connected!");
  },  },
  onDisconnected: function()  onDisconnected: function()
  {  {
- Console.print("Disconnected !");+ Console.print("Disconnected!");
  }  }
 }); });
Line 59: Line 60:
 === Notes === === Notes ===
 This method is asynchronous, this means that it will return before a connection is established. This method is asynchronous, this means that it will return before a connection is established.
-To known when a connection is made use the [[#onConnected|onConnected]] event or the [[#waitForConnected|waitForConnected]] method.+To know when a connection is made use the [[#onConnected|onConnected]] event or the [[#waitForConnected|waitForConnected]] method.
  
 ==== write ==== ==== write ====
Line 77: Line 78:
 === Notes === === Notes ===
 This method is asynchronous, this means that it will return before the data has been written. This method is asynchronous, this means that it will return before the data has been written.
-To known when the data has been sent use the [[#onBytesWritten|onBytesWritten]] event or the [[#waitForBytesWritten|waitForBytesWritten]] method.+To know when the data has been sent use the [[#onBytesWritten|onBytesWritten]] event or the [[#waitForBytesWritten|waitForBytesWritten]] method.
  
 ==== writeText ==== ==== writeText ====
Line 95: Line 96:
 === Notes === === Notes ===
 This method is asynchronous, this means that it will return before the data has been written. This method is asynchronous, this means that it will return before the data has been written.
-To known when the text has been sent use the [[#onBytesWritten|onBytesWritten]] event or the [[#waitForBytesWritten|waitForBytesWritten]] method.+To know when the text has been sent use the [[#onBytesWritten|onBytesWritten]] event or the [[#waitForBytesWritten|waitForBytesWritten]] method.
  
 ==== disconnect ==== ==== disconnect ====
Line 113: Line 114:
 === Notes === === Notes ===
 This method is asynchronous, this means that it will return before the connection is closed. This method is asynchronous, this means that it will return before the connection is closed.
-To known when the connection is closed use the [[#onDisconnected|onDisconnected]] event or the [[#waitForDisconnected|waitForDisconnected]] method.+To know when the connection is closed use the [[#onDisconnected|onDisconnected]] event or the [[#waitForDisconnected|waitForDisconnected]] method.
  
 ==== read ==== ==== read ====
Line 127: Line 128:
  
 === Notes === === Notes ===
-To known when data is available use the [[#onReadyRead|onReadyRead]] event or the [[#waitForReadyRead|waitForReadyRead]] method.+To know when data is available use the [[#onReadyRead|onReadyRead]] event or the [[#waitForReadyRead|waitForReadyRead]] method.
  
 ==== readText ==== ==== readText ====
Line 141: Line 142:
  
 === Arguments === === Arguments ===
-  - encoding - ([[code:core:global#encoding|Encoding]]) the encoding to use+  - encoding - ([[en:code:core:global#encoding|Encoding]]) the encoding to use
  
 === Returns === === Returns ===
Line 147: Line 148:
  
 === Notes === === Notes ===
-To known when text is available use the [[#onReadyRead|onReadyRead]] event or the [[#waitForReadyRead|waitForReadyRead]] method.+To know when text is available use the [[#onReadyRead|onReadyRead]] event or the [[#waitForReadyRead|waitForReadyRead]] method.
  
 ==== waitForConnected ==== ==== waitForConnected ====
Line 293: Line 294:
 <code javascript> <code javascript>
 myObject.onBytesWritten = function(bytes) myObject.onBytesWritten = function(bytes)
 +{
 + //Event action
 +};
 +</code>
 +
 +==== onError ====
 +Called when an error has occurred.
 +
 +=== Syntax ===
 +<code javascript>
 +myObject.onError = function(errorMessage) {};
 +</code>
 +
 +=== Arguments ===
 +  - errorMessage - (string) text describing the error
 +
 +=== Example ===
 +<code javascript>
 +myObject.errorMessage = function(errorMessage)
 { {
  //Event action  //Event action
Line 301: Line 321:
  
 ==== OpenMode ==== ==== OpenMode ====
-File open mode.+Open mode.
  
 === Values === === Values ===
Line 313: Line 333:
 Example: Example:
 <code javascript> <code javascript>
-myObject.connect("127.0.0.1", 80, File.ReadOnly | File.Unbuffered);+myObject.connect("127.0.0.1", 80, Tcp.ReadOnly | Tcp.Unbuffered);
 </code> </code>
en/code/data/tcp.1296160370.txt.gz · Last modified: 2021/02/13 11:23 (external edit)