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 [DartPackage="mojo_services"] | 5 [DartPackage="mojo_services"] |
6 module mojo; | 6 module mojo; |
7 | 7 |
8 import "mojo/public/interfaces/network/network_error.mojom"; | 8 import "mojo/public/interfaces/network/network_error.mojom"; |
9 import "network/interfaces/net_address.mojom"; | 9 import "network/interfaces/net_address.mojom"; |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
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. The socket must not be bound or | 26 // Binds the socket to the given address. The socket must not be bound or |
27 // connected. | 27 // connected. |
28 // |bound_addr| is non-null on success. It might not be the same as |addr|. | 28 // |bound_addr| is non-null on success. It might not be the same as |addr|. |
29 // For example, if port 0 is used in |addr|, an available port is picked and | 29 // For example, if port 0 is used in |addr|, an available port is picked and |
30 // returned in |bound_addr|. The caller may provide an implementation of | 30 // returned in |bound_addr|. The caller may provide an implementation of |
31 // |receiver| to receive datagrams read from the socket. |receiver| is null | 31 // |receiver| to receive datagrams read from the socket. |receiver| is null |
32 // on failure. | 32 // on failure. |
33 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr, | 33 Bind(NetAddress addr) |
34 UDPSocketReceiver&? receiver); | 34 => (NetworkError result, |
| 35 NetAddress? bound_addr, |
| 36 UDPSocketReceiver&? receiver); |
35 | 37 |
36 // Connects the socket to the remote address. The socket must not be bound or | 38 // Connects the socket to the remote address. The socket must not be bound or |
37 // connected. | 39 // connected. |
38 // |local_addr| is non-null on success. | 40 // |local_addr| is non-null on success. |
39 // The caller may provide an implementation of |receiver| to receive datagrams | 41 // The caller may provide an implementation of |receiver| to receive datagrams |
40 // read from the socket. |receiver| is null on failure. | 42 // read from the socket. |receiver| is null on failure. |
41 Connect(NetAddress remote_addr) => (NetworkError result, | 43 Connect(NetAddress remote_addr) |
42 NetAddress? local_addr, | 44 => (NetworkError result, |
43 UDPSocketReceiver&? receiver); | 45 NetAddress? local_addr, |
| 46 UDPSocketReceiver&? receiver); |
44 | 47 |
45 // Sets the OS send buffer size (in bytes) for the socket. The socket must be | 48 // Sets the OS send buffer size (in bytes) for the socket. The socket must be |
46 // bound or connected. | 49 // bound or connected. |
47 SetSendBufferSize(uint32 size) => (NetworkError result); | 50 SetSendBufferSize(uint32 size) => (NetworkError result); |
48 | 51 |
49 // Sets the OS receive buffer size (in bytes) for the socket. The socket must | 52 // Sets the OS receive buffer size (in bytes) for the socket. The socket must |
50 // be bound or connected. | 53 // be bound or connected. |
51 SetReceiveBufferSize(uint32 size) => (NetworkError result); | 54 SetReceiveBufferSize(uint32 size) => (NetworkError result); |
52 | 55 |
53 // Negotiates the maximum number of pending SendTo() requests. If | 56 // Negotiates the maximum number of pending SendTo() requests. If |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SendTo(NetAddress? dest_addr, array<uint8> data) => (NetworkError result); | 115 SendTo(NetAddress? dest_addr, array<uint8> data) => (NetworkError result); |
113 }; | 116 }; |
114 | 117 |
115 interface UDPSocketReceiver { | 118 interface UDPSocketReceiver { |
116 // On success, |data| is non-null, |src_addr| is non-null if the socket is | 119 // On success, |data| is non-null, |src_addr| is non-null if the socket is |
117 // not connected, |result.code| is a non-negative number indicating how many | 120 // not connected, |result.code| is a non-negative number indicating how many |
118 // bytes have been received. On failure, |result.code| is a network error | 121 // bytes have been received. On failure, |result.code| is a network error |
119 // code. | 122 // code. |
120 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); | 123 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); |
121 }; | 124 }; |
OLD | NEW |