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 applies to TCP sockets only. | |
Mihai Parparita -not on Chrome
2012/09/26 21:50:33
The documentation strings for these two methods sh
justinlin
2012/09/26 23:03:57
Done.
| |
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 callback will be | |
218 // invoked immediately with an error as the resultCode. | |
219 // |socketId| : The socketId. | |
220 // |callback| : The callback is invoked when a new socket is accepted. | |
221 static void accept(long socketId, | |
222 AcceptCallback callback); | |
223 | |
190 // Enables or disables the keep-alive functionality for a TCP connection. | 224 // Enables or disables the keep-alive functionality for a TCP connection. |
191 // |socketId| : The socketId. | 225 // |socketId| : The socketId. |
192 // |enable| : If true, enable keep-alive functionality. | 226 // |enable| : If true, enable keep-alive functionality. |
193 // |delay| : Set the delay seconds between the last data packet received | 227 // |delay| : Set the delay seconds between the last data packet received |
194 // and the first keepalive probe. Default is 0. | 228 // and the first keepalive probe. Default is 0. |
195 // |callback| : Called when the setKeepAlive attempt is complete. | 229 // |callback| : Called when the setKeepAlive attempt is complete. |
196 static void setKeepAlive(long socketId, | 230 static void setKeepAlive(long socketId, |
197 boolean enable, | 231 boolean enable, |
198 optional long delay, | 232 optional long delay, |
199 SetKeepAliveCallback callback); | 233 SetKeepAliveCallback callback); |
(...skipping 12 matching lines...) Expand all Loading... | |
212 // |callback| : Called when the state is available. | 246 // |callback| : Called when the state is available. |
213 static void getInfo(long socketId, | 247 static void getInfo(long socketId, |
214 GetInfoCallback callback); | 248 GetInfoCallback callback); |
215 | 249 |
216 // Retrieves information about local adapters on this system. | 250 // Retrieves information about local adapters on this system. |
217 // |callback| : Called when local adapter information is available. | 251 // |callback| : Called when local adapter information is available. |
218 static void getNetworkList(GetNetworkCallback callback); | 252 static void getNetworkList(GetNetworkCallback callback); |
219 }; | 253 }; |
220 | 254 |
221 }; | 255 }; |
OLD | NEW |