OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 import "mojo/services/public/interfaces/network/net_address.mojom" | 5 import "mojo/services/public/interfaces/network/net_address.mojom" |
6 import "mojo/services/public/interfaces/network/network_error.mojom" | 6 import "mojo/services/public/interfaces/network/network_error.mojom" |
7 | 7 |
8 module mojo { | 8 module mojo { |
9 | 9 |
10 // UDPSocket and UDPSocketClient represent a UDP socket and its client. The | 10 // UDPSocket and UDPSocketClient represent a UDP socket and its client. The |
11 // typical flow of using the interfaces is: | 11 // typical flow of using the interfaces is: |
12 // - Acquire a UDPSocket interface pointer and set a UDPSocketClient instance. | 12 // - Acquire a UDPSocket interface pointer and set a UDPSocketClient instance. |
13 // - (optional) Set options which are allowed prior to Bind(). | 13 // - (optional) Set options which are allowed prior to Bind(). |
14 // - Bind the socket. | 14 // - Bind the socket. |
15 // - (optional) Set options which are allowed after Bind(). | 15 // - (optional) Set options which are allowed after Bind(). |
16 // - Send / request to receive packets. Received packets will be delivered to | 16 // - Send / request to receive packets. Received packets will be delivered to |
17 // UDPSocketClient.OnReceived(). | 17 // UDPSocketClient.OnReceived(). |
18 | |
18 [Client=UDPSocketClient] | 19 [Client=UDPSocketClient] |
19 interface UDPSocket { | 20 interface UDPSocket { |
20 // Allows the socket to share the local address to which it will be bound with | 21 // Allows the socket to share the local address to which it will be bound with |
21 // other processes. Should be called before Bind(). | 22 // other processes. Should be called before Bind(). |
22 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) | 23 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) |
23 AllowAddressReuse() => (NetworkError result); | 24 AllowAddressReuse() => (NetworkError result); |
24 | 25 |
25 // Binds the socket to the given address. | 26 // Binds the socket to the given address. |
26 // |bound_addr| is non-NULL on success. It might not be the same as |addr|. | 27 // |bound_addr| is non-NULL on success. It might not be the same as |addr|. |
27 // For example, if port 0 is used in |addr|, a random port is picked and | 28 // For example, if port 0 is used in |addr|, a random port is picked and |
28 // returned in |bound_addr|. | 29 // returned in |bound_addr|. |
29 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); | 30 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); |
30 | 31 |
31 // Sets the send buffer size (in bytes) for the socket. The socket must be | 32 // Sets the send buffer size (in bytes) for the socket. The socket must be |
32 // bound. | 33 // bound. |
33 // | 34 // |
34 // Note: This is only treated as a hint. Even if it succeeds, the service | 35 // Note: This is only treated as a hint. Even if it succeeds, the service |
willchan no longer on Chromium
2014/09/30 22:17:33
What does this note mean?
It's not obvious if the
yzshen1
2014/09/30 22:55:09
This is a note copied from the Pepper API, because
willchan no longer on Chromium
2014/10/01 00:56:45
Do you think it's worthwhile to clarify that in th
| |
35 // doesn't guarantee it will conform to the size. | 36 // doesn't guarantee it will conform to the size. |
36 SetSendBufferSize(uint32 size) => (NetworkError result); | 37 SetSendBufferSize(uint32 size) => (NetworkError result); |
37 | 38 |
38 // Sets the receive buffer size (in bytes) for the socket. The socket must be | 39 // Sets the receive buffer size (in bytes) for the socket. The socket must be |
39 // bound. | 40 // bound. |
40 // | 41 // |
41 // Note: This is only treated as a hint. Even if it succeeds, the service | 42 // Note: This is only treated as a hint. Even if it succeeds, the service |
42 // doesn't guarantee it will conform to the size. | 43 // doesn't guarantee it will conform to the size. |
43 SetReceiveBufferSize(uint32 size) => (NetworkError result); | 44 SetReceiveBufferSize(uint32 size) => (NetworkError result); |
44 | 45 |
(...skipping 15 matching lines...) Expand all Loading... | |
60 | 61 |
61 // Sends data to the specified destination. The socket must be bound. | 62 // Sends data to the specified destination. The socket must be bound. |
62 // The method doesn't report the result of the operation. | 63 // The method doesn't report the result of the operation. |
63 SendToAndForget(NetAddress addr, uint8[] data); | 64 SendToAndForget(NetAddress addr, uint8[] data); |
64 | 65 |
65 // Sends data to the specified destination. The socket must be bound. | 66 // Sends data to the specified destination. The socket must be bound. |
66 SendTo(NetAddress addr, uint8[] data) => (NetworkError result); | 67 SendTo(NetAddress addr, uint8[] data) => (NetworkError result); |
67 }; | 68 }; |
68 | 69 |
69 interface UDPSocketClient { | 70 interface UDPSocketClient { |
70 // |addr| and |data| are non-NULL on success. | 71 // |addr| and |data| are non-NULL on success. |
wtc
2014/10/02 02:00:52
Nit: document what |addr| is, or rename it |peer_a
yzshen1
2014/10/02 19:15:27
Done. I used "src_addr" and also changed the param
| |
71 OnReceived(NetworkError result, NetAddress? addr, uint8[]? data); | 72 OnReceived(NetworkError result, NetAddress? addr, uint8[]? data); |
72 }; | 73 }; |
73 | 74 |
74 } | 75 } |
OLD | NEW |