Alexander Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame^] | 1 | TcpTransport.ConnectionInfo Class |
| 2 | ================================= |
| 3 | |
| 4 | :[C++]: |
| 5 | Namespace: ndn |
| 6 | |
| 7 | A TcpTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the host and port info for the TCP connection. |
| 8 | |
| 9 | TcpTransport.ConnectionInfo Constructor |
| 10 | --------------------------------------- |
| 11 | |
| 12 | Create a TcpTransport.ConnectionInfo with the given host and port. |
| 13 | |
| 14 | :[C++]: |
| 15 | |
| 16 | .. code-block:: c++ |
| 17 | |
| 18 | TcpTransport( |
| 19 | |
| 20 | const char *host |
| 21 | [, unsigned short port] |
| 22 | |
| 23 | ); |
| 24 | |
| 25 | :Parameters: |
| 26 | |
| 27 | - `host` |
| 28 | The host for the connection. |
| 29 | |
| 30 | - `port` |
| 31 | (optional) The port number for the connection. If omitted, use 9695. |
| 32 | |
| 33 | .. _TcpTransport: |
| 34 | |
| 35 | TcpTransport Class |
| 36 | ================== |
| 37 | |
| 38 | :[C++]: |
| 39 | |
| 40 | Namespace: `ndn` |
| 41 | |
| 42 | TcpTransport Constructor |
| 43 | ------------------------ |
| 44 | |
| 45 | Create a TcpTransport which extends the Transport interface to implement communication over TCP/IP. |
| 46 | |
| 47 | :[C++]: |
| 48 | |
| 49 | .. code-block:: c++ |
| 50 | |
| 51 | TcpTransport(); |
| 52 | |
| 53 | :[JavaScript]: |
| 54 | |
| 55 | .. code-block:: javascript |
| 56 | |
| 57 | var TcpTransport = function TcpTransport() |
| 58 | |
| 59 | TcpTransport.connect Method |
| 60 | --------------------------- |
| 61 | |
| 62 | Connect according to the info in ConnectionInfo, and use elementListener to receive data. |
| 63 | |
| 64 | :[C++]: |
| 65 | |
| 66 | .. code-block:: c++ |
| 67 | |
| 68 | void connect( |
| 69 | |
| 70 | const Transport::ConnectionInfo& connectionInfo, |
| 71 | ElementListener& elementListener |
| 72 | |
| 73 | ); |
| 74 | |
| 75 | :[JavaScript]: |
| 76 | |
| 77 | .. code-block:: javascript |
| 78 | |
| 79 | TcpTransport.prototype.connect = function( |
| 80 | |
| 81 | ndn // NDN |
| 82 | |
| 83 | ) |
| 84 | |
| 85 | :Parameters: |
| 86 | |
| 87 | - `connectionInfo` |
| 88 | A TcpTransport.ConnectionInfo with the info for connecting. |
| 89 | |
| 90 | - `elementListener` |
| 91 | The ElementListener called when an element is received. |
| 92 | |
| 93 | TcpTransport.send Method |
| 94 | ------------------------ |
| 95 | |
| 96 | Send the data over the connection. |
| 97 | |
| 98 | :[C++]: |
| 99 | |
| 100 | .. code-block:: c++ |
| 101 | |
| 102 | void send( |
| 103 | |
| 104 | const uint8_t* data, |
| 105 | size_t dataLength |
| 106 | |
| 107 | ); |
| 108 | |
| 109 | :[JavaScript]: |
| 110 | |
| 111 | .. code-block:: javascript |
| 112 | |
| 113 | TcpTransport.prototype.send = function( |
| 114 | |
| 115 | data // Uint8Array |
| 116 | |
| 117 | ) |
| 118 | |
| 119 | :Parameters: |
| 120 | |
| 121 | - `data` |
| 122 | The data byte array to send. |
| 123 | |
| 124 | - `dataLength` |
| 125 | (C++ only) The length of the data byte array. |