| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // File-level comment to appease parser. Eventually this will not be necessary. | 5 // File-level comment to appease parser. Eventually this will not be necessary. |
| 6 | 6 |
| 7 namespace experimental.socket { | 7 namespace experimental.socket { |
| 8 enum SocketType { | 8 enum SocketType { |
| 9 tcp, | 9 tcp, |
| 10 udp | 10 udp |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 callback ReadCallback = void (ReadInfo readInfo); | 38 callback ReadCallback = void (ReadInfo readInfo); |
| 39 | 39 |
| 40 dictionary WriteInfo { | 40 dictionary WriteInfo { |
| 41 // The number of bytes sent, or a negative error code. | 41 // The number of bytes sent, or a negative error code. |
| 42 long bytesWritten; | 42 long bytesWritten; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 callback WriteCallback = void (WriteInfo writeInfo); | 45 callback WriteCallback = void (WriteInfo writeInfo); |
| 46 | 46 |
| 47 dictionary RecvFromInfo { | 47 dictionary RecvFromInfo { |
| 48 // The resultCode returned from the underlying read() call. | 48 // The resultCode returned from the underlying recvfrom() call. |
| 49 long resultCode; | 49 long resultCode; |
| 50 | 50 |
| 51 ArrayBuffer data; | 51 ArrayBuffer data; |
| 52 |
| 53 // The address of the remote machine. |
| 52 DOMString address; | 54 DOMString address; |
| 55 |
| 53 long port; | 56 long port; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); | 59 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); |
| 57 | 60 |
| 58 callback SendToCallback = void (WriteInfo writeInfo); | 61 callback SendToCallback = void (WriteInfo writeInfo); |
| 59 | 62 |
| 60 callback SetKeepAliveCallback = void (boolean result); | 63 callback SetKeepAliveCallback = void (boolean result); |
| 61 | 64 |
| 62 callback SetNoDelayCallback = void (boolean result); | 65 callback SetNoDelayCallback = void (boolean result); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 static void bind(long socketId, | 98 static void bind(long socketId, |
| 96 DOMString address, | 99 DOMString address, |
| 97 long port, | 100 long port, |
| 98 BindCallback callback); | 101 BindCallback callback); |
| 99 | 102 |
| 100 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a | 103 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a |
| 101 // non-operation but is safe to call. | 104 // non-operation but is safe to call. |
| 102 // |socketId| : The socketId. | 105 // |socketId| : The socketId. |
| 103 static void disconnect(long socketId); | 106 static void disconnect(long socketId); |
| 104 | 107 |
| 105 // Reads data from the given socket. | 108 // Reads data from the given connected socket. |
| 106 // |socketId| : The socketId. | 109 // |socketId| : The socketId. |
| 107 // |bufferSize| : The read buffer size. | 110 // |bufferSize| : The read buffer size. |
| 108 // |callback| : Delivers data that was available to be read without | 111 // |callback| : Delivers data that was available to be read without |
| 109 // blocking. | 112 // blocking. |
| 110 static void read(long socketId, | 113 static void read(long socketId, |
| 111 optional long bufferSize, | 114 optional long bufferSize, |
| 112 ReadCallback callback); | 115 ReadCallback callback); |
| 113 | 116 |
| 114 // Writes data on the given socket. | 117 // Writes data on the given connected socket. |
| 115 // |socketId| : The socketId. | 118 // |socketId| : The socketId. |
| 116 // |data| : The data to write. | 119 // |data| : The data to write. |
| 117 // |callback| : Called when the first of any of the following happens: the | 120 // |callback| : Called when the write operation completes without blocking |
| 118 // write operation completes without blocking, the write operation blocked | 121 // or an error occurs. |
| 119 // before completion (in which case onEvent() will eventually be called with | |
| 120 // a <code>writeComplete</code> event), or an error occurred. | |
| 121 static void write(long socketId, | 122 static void write(long socketId, |
| 122 ArrayBuffer data, | 123 ArrayBuffer data, |
| 123 WriteCallback callback); | 124 WriteCallback callback); |
| 124 | 125 |
| 125 // Reads data from the given socket. | 126 // Receives data from the given UDP socket. |
| 126 // |socketId| : The socketId. | 127 // |socketId| : The socketId. |
| 127 // |bufferSize| : The receive buffer size. | 128 // |bufferSize| : The receive buffer size. |
| 128 // |callback| : Delivers data that was available to be read without | 129 // |callback| : Returns result of the recvFrom operation. |
| 129 // blocking. | |
| 130 static void recvFrom(long socketId, | 130 static void recvFrom(long socketId, |
| 131 optional long bufferSize, | 131 optional long bufferSize, |
| 132 RecvFromCallback callback); | 132 RecvFromCallback callback); |
| 133 | 133 |
| 134 // Writes data on the given socket. | 134 // Sends data on the given UDP socket to the given address and port. |
| 135 // |socketId| : The socketId. | 135 // |socketId| : The socketId. |
| 136 // |data| : The data to write. | 136 // |data| : The data to write. |
| 137 // |address| : The address of the remote machine. | 137 // |address| : The address of the remote machine. |
| 138 // |port| : The port of the remote machine. | 138 // |port| : The port of the remote machine. |
| 139 // |callback| : Called when the first of any of the following happens: the | 139 // |callback| : Called when the send operation completes without blocking |
| 140 // write operation completes without blocking, the write operation blocked | 140 // or an error occurs. |
| 141 // before completion (in which case onEvent() will eventually be called with | |
| 142 // a <code>writeComplete</code> event), or an error occurred. | |
| 143 static void sendTo(long socketId, | 141 static void sendTo(long socketId, |
| 144 ArrayBuffer data, | 142 ArrayBuffer data, |
| 145 DOMString address, | 143 DOMString address, |
| 146 long port, | 144 long port, |
| 147 SendToCallback callback); | 145 SendToCallback callback); |
| 148 | 146 |
| 149 // Enable/disable keep-alive functionality for a TCP connection. | 147 // Enable/disable keep-alive functionality for a TCP connection. |
| 150 // |socketId| : The socketId. | 148 // |socketId| : The socketId. |
| 151 // |enable| : If true, enable keep-alive functionality. | 149 // |enable| : If true, enable keep-alive functionality. |
| 152 // |delay| : Set the delay seconds between the last data packet received | 150 // |delay| : Set the delay seconds between the last data packet received |
| 153 // and the first keepalive probe. Default is 0. | 151 // and the first keepalive probe. Default is 0. |
| 154 // |callback| : Called when the setKeepAlive attempt is complete. | 152 // |callback| : Called when the setKeepAlive attempt is complete. |
| 155 static void setKeepAlive(long socketId, | 153 static void setKeepAlive(long socketId, |
| 156 boolean enable, | 154 boolean enable, |
| 157 optional long delay, | 155 optional long delay, |
| 158 SetKeepAliveCallback callback); | 156 SetKeepAliveCallback callback); |
| 159 | 157 |
| 160 // Enable/disable Nagle algorithm. | 158 // Enable/disable Nagle algorithm. |
| 161 // |socketId| : The socketId. | 159 // |socketId| : The socketId. |
| 162 // |noDelay| : If true, disable Nagle algorithm. | 160 // |noDelay| : If true, disable Nagle algorithm. |
| 163 // |callback| : Called when the setNoDelay attempt is complete. | 161 // |callback| : Called when the setNoDelay attempt is complete. |
| 164 static void setNoDelay(long socketId, | 162 static void setNoDelay(long socketId, |
| 165 boolean noDelay, | 163 boolean noDelay, |
| 166 SetNoDelayCallback callback); | 164 SetNoDelayCallback callback); |
| 167 }; | 165 }; |
| 168 | 166 |
| 169 }; | 167 }; |
| OLD | NEW |