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 datagrams. Received datagrams will be delivered | 16 // - Send / request to receive datagrams. Received datagrams will be delivered |
17 // to UDPSocketClient.OnReceived(). | 17 // to UDPSocketClient.OnReceived(). |
18 | 18 |
19 [Client=UDPSocketClient] | 19 [Client=UDPSocketClient] |
20 interface UDPSocket { | 20 interface UDPSocket { |
21 // 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 |
22 // other processes. Should be called before Bind(). | 22 // other processes. Should be called before Bind(). |
23 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) | 23 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) |
24 AllowAddressReuse() => (NetworkError result); | 24 AllowAddressReuse() => (NetworkError result); |
25 | 25 |
26 // Binds the socket to the given address. | 26 // Binds the socket to the given address. |
27 // |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|. |
28 // 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|, an available port is picked and |
29 // returned in |bound_addr|. | 29 // returned in |bound_addr|. |
30 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); | 30 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); |
31 | 31 |
32 // Sets the OS send buffer size (in bytes) for the socket. The socket must be | 32 // Sets the OS send buffer size (in bytes) for the socket. The socket must be |
33 // bound. | 33 // bound. |
34 SetSendBufferSize(uint32 size) => (NetworkError result); | 34 SetSendBufferSize(uint32 size) => (NetworkError result); |
35 | 35 |
36 // Sets the OS receive buffer size (in bytes) for the socket. The socket must | 36 // Sets the OS receive buffer size (in bytes) for the socket. The socket must |
37 // be bound. | 37 // be bound. |
38 SetReceiveBufferSize(uint32 size) => (NetworkError result); | 38 SetReceiveBufferSize(uint32 size) => (NetworkError result); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }; | 99 }; |
100 | 100 |
101 interface UDPSocketClient { | 101 interface UDPSocketClient { |
102 // On success, |src_addr| and |data| are non-NULL, and |result.code| is a | 102 // On success, |src_addr| and |data| are non-NULL, and |result.code| is a |
103 // non-negative number indicating how many bytes have been received. On | 103 // non-negative number indicating how many bytes have been received. On |
104 // failure, |result.code| is a network error code. | 104 // failure, |result.code| is a network error code. |
105 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); | 105 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); |
106 }; | 106 }; |
107 | 107 |
108 } | 108 } |
OLD | NEW |