| 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 namespace socket { | 5 namespace socket { |
| 6 enum SocketType { | 6 enum SocketType { |
| 7 tcp, | 7 tcp, |
| 8 udp | 8 udp |
| 9 }; | 9 }; |
| 10 | 10 |
| 11 // The socket options. | 11 // The socket options. |
| 12 dictionary CreateOptions { | 12 dictionary CreateOptions { |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 dictionary CreateInfo { | 15 dictionary CreateInfo { |
| 16 // The id of the newly created socket. | 16 // The id of the newly created socket. |
| 17 long socketId; | 17 long socketId; |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 callback CreateCallback = void (CreateInfo createInfo); | 20 callback CreateCallback = void (CreateInfo createInfo); |
| 21 | 21 |
| 22 callback ConnectCallback = void (long result); | 22 callback ConnectCallback = void (long result); |
| 23 | 23 |
| 24 callback BindCallback = void (long result); | 24 callback BindCallback = void (long result); |
| 25 | 25 |
| 26 callback ListenCallback = void (long result); |
| 27 |
| 28 dictionary AcceptInfo { |
| 29 // The id of the accepted socket. |
| 30 long socketId; |
| 31 long resultCode; |
| 32 }; |
| 33 |
| 34 callback AcceptCallback = void (AcceptInfo acceptInfo); |
| 35 |
| 26 dictionary ReadInfo { | 36 dictionary ReadInfo { |
| 27 // The resultCode returned from the underlying read() call. | 37 // The resultCode returned from the underlying read() call. |
| 28 long resultCode; | 38 long resultCode; |
| 29 | 39 |
| 30 ArrayBuffer data; | 40 ArrayBuffer data; |
| 31 }; | 41 }; |
| 32 | 42 |
| 33 callback ReadCallback = void (ReadInfo readInfo); | 43 callback ReadCallback = void (ReadInfo readInfo); |
| 34 | 44 |
| 35 dictionary WriteInfo { | 45 dictionary WriteInfo { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // |address| : The address of the remote machine. | 190 // |address| : The address of the remote machine. |
| 181 // |port| : The port of the remote machine. | 191 // |port| : The port of the remote machine. |
| 182 // |callback| : Called when the send operation completes without blocking | 192 // |callback| : Called when the send operation completes without blocking |
| 183 // or an error occurs. | 193 // or an error occurs. |
| 184 static void sendTo(long socketId, | 194 static void sendTo(long socketId, |
| 185 ArrayBuffer data, | 195 ArrayBuffer data, |
| 186 DOMString address, | 196 DOMString address, |
| 187 long port, | 197 long port, |
| 188 SendToCallback callback); | 198 SendToCallback callback); |
| 189 | 199 |
| 200 // This method applies to TCP sockets only. |
| 201 // Listens for connections on the specified port and address. This |
| 202 // effectively makes this a server socket, and client socket |
| 203 // functions (connect, read, write) can no longer be used on this socket. |
| 204 // |socketId| : The socketId. |
| 205 // |address| : The address of the local machine. |
| 206 // |port| : The port of the local machine. |
| 207 // |backlog| : Length of the socket's listen queue. |
| 208 static void listen(long socketId, |
| 209 DOMString address, |
| 210 long port, |
| 211 optional long backlog, |
| 212 ListenCallback callback); |
| 213 |
| 214 // This method applies to TCP sockets only. |
| 215 // Registers a callback function to be called when a connection is |
| 216 // accepted on this listening server socket. Listen must be called first. |
| 217 // If there is already an active accept callback, this call will fail. |
| 218 // |socketId| : The socketId. |
| 219 // |callback| : The callback is invoked when a new socket is accepted. |
| 220 static void accept(long socketId, |
| 221 AcceptCallback callback); |
| 222 |
| 190 // Enables or disables the keep-alive functionality for a TCP connection. | 223 // Enables or disables the keep-alive functionality for a TCP connection. |
| 191 // |socketId| : The socketId. | 224 // |socketId| : The socketId. |
| 192 // |enable| : If true, enable keep-alive functionality. | 225 // |enable| : If true, enable keep-alive functionality. |
| 193 // |delay| : Set the delay seconds between the last data packet received | 226 // |delay| : Set the delay seconds between the last data packet received |
| 194 // and the first keepalive probe. Default is 0. | 227 // and the first keepalive probe. Default is 0. |
| 195 // |callback| : Called when the setKeepAlive attempt is complete. | 228 // |callback| : Called when the setKeepAlive attempt is complete. |
| 196 static void setKeepAlive(long socketId, | 229 static void setKeepAlive(long socketId, |
| 197 boolean enable, | 230 boolean enable, |
| 198 optional long delay, | 231 optional long delay, |
| 199 SetKeepAliveCallback callback); | 232 SetKeepAliveCallback callback); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 212 // |callback| : Called when the state is available. | 245 // |callback| : Called when the state is available. |
| 213 static void getInfo(long socketId, | 246 static void getInfo(long socketId, |
| 214 GetInfoCallback callback); | 247 GetInfoCallback callback); |
| 215 | 248 |
| 216 // Retrieves information about local adapters on this system. | 249 // Retrieves information about local adapters on this system. |
| 217 // |callback| : Called when local adapter information is available. | 250 // |callback| : Called when local adapter information is available. |
| 218 static void getNetworkList(GetNetworkCallback callback); | 251 static void getNetworkList(GetNetworkCallback callback); |
| 219 }; | 252 }; |
| 220 | 253 |
| 221 }; | 254 }; |
| OLD | NEW |