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 // Use the <code>chrome.socket</code> API to send and receive data over the |
| 6 // network using TCP and UDP connections. |
5 namespace socket { | 7 namespace socket { |
6 enum SocketType { | 8 enum SocketType { |
7 tcp, | 9 tcp, |
8 udp | 10 udp |
9 }; | 11 }; |
10 | 12 |
11 // The socket options. | 13 // The socket options. |
12 dictionary CreateOptions { | 14 dictionary CreateOptions { |
13 }; | 15 }; |
14 | 16 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 262 |
261 // Retrieves information about local adapters on this system. | 263 // Retrieves information about local adapters on this system. |
262 // |callback| : Called when local adapter information is available. | 264 // |callback| : Called when local adapter information is available. |
263 static void getNetworkList(GetNetworkCallback callback); | 265 static void getNetworkList(GetNetworkCallback callback); |
264 | 266 |
265 // Join the multicast group and start to receive packets from that group. | 267 // Join the multicast group and start to receive packets from that group. |
266 // The socket must be of UDP type and must be bound to a local port | 268 // The socket must be of UDP type and must be bound to a local port |
267 // before calling this method. | 269 // before calling this method. |
268 // |socketId| : The socketId. | 270 // |socketId| : The socketId. |
269 // |address| : The group address to join. Domain names are not supported. | 271 // |address| : The group address to join. Domain names are not supported. |
270 // |callback| : Called when the join group operation is done with an | 272 // |callback| : Called when the join group operation is done with an |
271 // integer parameter indicating the platform-independent error code. | 273 // integer parameter indicating the platform-independent error code. |
272 static void joinGroup(long socketId, | 274 static void joinGroup(long socketId, |
273 DOMString address, | 275 DOMString address, |
274 JoinGroupCallback callback); | 276 JoinGroupCallback callback); |
275 | 277 |
276 // Leave the multicast group previously joined using <code>joinGroup</code>. | 278 // Leave the multicast group previously joined using <code>joinGroup</code>. |
277 // It's not necessary to leave the multicast group before destroying the | 279 // It's not necessary to leave the multicast group before destroying the |
278 // socket or exiting. This is automatically called by the OS. | 280 // socket or exiting. This is automatically called by the OS. |
279 // | 281 // |
280 // Leaving the group will prevent the router from sending multicast | 282 // Leaving the group will prevent the router from sending multicast |
281 // datagrams to the local host, presuming no other process on the host is | 283 // datagrams to the local host, presuming no other process on the host is |
282 // still joined to the group. | 284 // still joined to the group. |
283 // | 285 // |
284 // |socketId| : The socketId. | 286 // |socketId| : The socketId. |
285 // |address| : The group address to leave. Domain names are not supported. | 287 // |address| : The group address to leave. Domain names are not supported. |
286 // |callback| : Called when the leave group operation is done with an | 288 // |callback| : Called when the leave group operation is done with an |
287 // integer parameter indicating the platform-independent error code. | 289 // integer parameter indicating the platform-independent error code. |
288 static void leaveGroup(long socketId, DOMString address, | 290 static void leaveGroup(long socketId, DOMString address, |
289 LeaveGroupCallback callback); | 291 LeaveGroupCallback callback); |
290 | 292 |
291 // Set the time-to-live of multicast packets sent to the multicast group. | 293 // Set the time-to-live of multicast packets sent to the multicast group. |
292 // | 294 // |
293 // Calling this method does not require multicast permissions. | 295 // Calling this method does not require multicast permissions. |
294 // | 296 // |
295 // |socketId| : The socketId. | 297 // |socketId| : The socketId. |
296 // |ttl| : The time-to-live value. | 298 // |ttl| : The time-to-live value. |
297 // |callback| : Called when the configuration operation is done. | 299 // |callback| : Called when the configuration operation is done. |
298 static void setMulticastTimeToLive( | 300 static void setMulticastTimeToLive( |
299 long socketId, | 301 long socketId, |
300 long ttl, | 302 long ttl, |
301 SetMulticastTimeToLiveCallback callback); | 303 SetMulticastTimeToLiveCallback callback); |
302 | 304 |
303 // Set whether multicast packets sent from the host to the multicast | 305 // Set whether multicast packets sent from the host to the multicast |
304 // group will be looped back to the host. | 306 // group will be looped back to the host. |
305 // | 307 // |
306 // Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly | 308 // Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly |
307 // different between Windows and Unix-like systems. The inconsistency | 309 // different between Windows and Unix-like systems. The inconsistency |
308 // happens only when there is more than one application on the same host | 310 // happens only when there is more than one application on the same host |
309 // joined to the same multicast group while having different settings on | 311 // joined to the same multicast group while having different settings on |
310 // multicast loopback mode. On Windows, the applications with loopback off | 312 // multicast loopback mode. On Windows, the applications with loopback off |
311 // will not RECEIVE the loopback packets; while on Unix-like systems, the | 313 // will not RECEIVE the loopback packets; while on Unix-like systems, the |
312 // applications with loopback off will not SEND the loopback packets to | 314 // applications with loopback off will not SEND the loopback packets to |
313 // other applications on the same host. See MSDN: http://goo.gl/6vqbj | 315 // other applications on the same host. See MSDN: http://goo.gl/6vqbj |
314 // | 316 // |
315 // Calling this method does not require multicast permissions. | 317 // Calling this method does not require multicast permissions. |
316 // | 318 // |
317 // |socketId| : The socketId. | 319 // |socketId| : The socketId. |
318 // |enabled| : Indicate whether to enable loopback mode. | 320 // |enabled| : Indicate whether to enable loopback mode. |
319 // |callback| : Called when the configuration operation is done. | 321 // |callback| : Called when the configuration operation is done. |
320 static void setMulticastLoopbackMode( | 322 static void setMulticastLoopbackMode( |
321 long socketId, | 323 long socketId, |
322 boolean enabled, | 324 boolean enabled, |
323 SetMulticastLoopbackModeCallback callback); | 325 SetMulticastLoopbackModeCallback callback); |
324 | 326 |
325 // Get the multicast group addresses the socket is currently joined to. | 327 // Get the multicast group addresses the socket is currently joined to. |
326 // |socketId| : The socketId. | 328 // |socketId| : The socketId. |
327 // |callback| : Called with an array of strings of the result. | 329 // |callback| : Called with an array of strings of the result. |
328 static void getJoinedGroups(long socketId, | 330 static void getJoinedGroups(long socketId, |
329 GetJoinedGroupsCallback callback); | 331 GetJoinedGroupsCallback callback); |
330 }; | 332 }; |
331 | 333 |
332 }; | 334 }; |
OLD | NEW |