| 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 long resultCode; |
| 30 // The id of the accepted socket. |
| 31 long? socketId; |
| 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 is experimental and requires experimental API permission. |
| 201 // This method applies to TCP sockets only. |
| 202 // Listens for connections on the specified port and address. This |
| 203 // effectively makes this a server socket, and client socket |
| 204 // functions (connect, read, write) can no longer be used on this socket. |
| 205 // |socketId| : The socketId. |
| 206 // |address| : The address of the local machine. |
| 207 // |port| : The port of the local machine. |
| 208 // |backlog| : Length of the socket's listen queue. |
| 209 static void listen(long socketId, |
| 210 DOMString address, |
| 211 long port, |
| 212 optional long backlog, |
| 213 ListenCallback callback); |
| 214 |
| 215 // This method is experimental and requires experimental API permission. |
| 216 // This method applies to TCP sockets only. |
| 217 // Registers a callback function to be called when a connection is |
| 218 // accepted on this listening server socket. Listen must be called first. |
| 219 // If there is already an active accept callback, this callback will be |
| 220 // invoked immediately with an error as the resultCode. |
| 221 // |socketId| : The socketId. |
| 222 // |callback| : The callback is invoked when a new socket is accepted. |
| 223 static void accept(long socketId, |
| 224 AcceptCallback callback); |
| 225 |
| 190 // Enables or disables the keep-alive functionality for a TCP connection. | 226 // Enables or disables the keep-alive functionality for a TCP connection. |
| 191 // |socketId| : The socketId. | 227 // |socketId| : The socketId. |
| 192 // |enable| : If true, enable keep-alive functionality. | 228 // |enable| : If true, enable keep-alive functionality. |
| 193 // |delay| : Set the delay seconds between the last data packet received | 229 // |delay| : Set the delay seconds between the last data packet received |
| 194 // and the first keepalive probe. Default is 0. | 230 // and the first keepalive probe. Default is 0. |
| 195 // |callback| : Called when the setKeepAlive attempt is complete. | 231 // |callback| : Called when the setKeepAlive attempt is complete. |
| 196 static void setKeepAlive(long socketId, | 232 static void setKeepAlive(long socketId, |
| 197 boolean enable, | 233 boolean enable, |
| 198 optional long delay, | 234 optional long delay, |
| 199 SetKeepAliveCallback callback); | 235 SetKeepAliveCallback callback); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 212 // |callback| : Called when the state is available. | 248 // |callback| : Called when the state is available. |
| 213 static void getInfo(long socketId, | 249 static void getInfo(long socketId, |
| 214 GetInfoCallback callback); | 250 GetInfoCallback callback); |
| 215 | 251 |
| 216 // Retrieves information about local adapters on this system. | 252 // Retrieves information about local adapters on this system. |
| 217 // |callback| : Called when local adapter information is available. | 253 // |callback| : Called when local adapter information is available. |
| 218 static void getNetworkList(GetNetworkCallback callback); | 254 static void getNetworkList(GetNetworkCallback callback); |
| 219 }; | 255 }; |
| 220 | 256 |
| 221 }; | 257 }; |
| OLD | NEW |