Alexander Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 1 | UdpTransport.ConnectionInfo Class |
| 2 | ================================= |
| 3 | |
| 4 | :[C++]: |
| 5 | Namespace: `ndn` |
| 6 | |
| 7 | A UdpTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the host and port info for the UDP connection. |
| 8 | |
| 9 | UdpTransport.ConnectionInfo Constructor |
| 10 | --------------------------------------- |
| 11 | |
| 12 | Create a UdpTransport.ConnectionInfo with the given host and port. |
| 13 | |
| 14 | :[C++]: |
| 15 | |
| 16 | .. code-block:: c++ |
| 17 | |
| 18 | UdpTransport( |
| 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 | .. _UdpTransport: |
| 34 | |
| 35 | UdpTransport Class |
| 36 | ================== |
| 37 | |
| 38 | :[C++]: |
| 39 | Namespace: `ndn` |
| 40 | |
| 41 | UdpTransport Constructor |
| 42 | ------------------------ |
| 43 | |
| 44 | Create a UdpTransport which extends the Transport interface to implement communication over UDP. |
| 45 | |
| 46 | :[C++]: |
| 47 | |
| 48 | .. code-block:: c++ |
| 49 | |
| 50 | UdpTransport(); |
| 51 | |
| 52 | UdpTransport.connect Method |
| 53 | --------------------------- |
| 54 | |
| 55 | Connect according to the info in ConnectionInfo, and use elementListener to receive data. |
| 56 | |
| 57 | :[C++]: |
| 58 | |
| 59 | .. code-block:: c++ |
| 60 | |
| 61 | void connect( |
| 62 | |
| 63 | const Transport::ConnectionInfo& connectionInfo, |
| 64 | ElementListener& elementListener |
| 65 | |
| 66 | ); |
| 67 | |
| 68 | :[JavaScript]: |
| 69 | |
| 70 | .. code-block:: javascript |
| 71 | |
| 72 | TcpTransport.prototype.connect = function( |
| 73 | |
| 74 | ndn // NDN |
| 75 | |
| 76 | ) |
| 77 | |
| 78 | :Parameters: |
| 79 | |
| 80 | - `connectionInfo` |
| 81 | A UdpTransport.ConnectionInfo with the info for connecting. |
| 82 | |
| 83 | - `elementListener` |
| 84 | The ElementListener called when an element is received |
| 85 | |
| 86 | UdpTransport.send Method |
| 87 | ------------------------ |
| 88 | |
| 89 | Send the data over the connection. |
| 90 | |
| 91 | :[C++]: |
| 92 | |
| 93 | .. code-block:: c++ |
| 94 | |
| 95 | void send( |
| 96 | |
| 97 | const uint8_t* data, |
| 98 | size_t dataLength |
| 99 | |
| 100 | ); |
| 101 | |
| 102 | :Parameters: |
| 103 | |
| 104 | - `data` |
| 105 | The data byte array to send. |
| 106 | |
| 107 | - `dataLength` |
| 108 | (C++ only) The length of the data byte array. |