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) => (NetworkError result, NetAddress? bound_addr, UDPSock
etReceiver&? receiver); |
34 UDPSocketReceiver&? receiver); | |
35 | 34 |
36 // Connects the socket to the remote address. The socket must not be bound or | 35 // Connects the socket to the remote address. The socket must not be bound or |
37 // connected. | 36 // connected. |
38 // |local_addr| is non-null on success. | 37 // |local_addr| is non-null on success. |
39 // The caller may provide an implementation of |receiver| to receive datagrams | 38 // The caller may provide an implementation of |receiver| to receive datagrams |
40 // read from the socket. |receiver| is null on failure. | 39 // read from the socket. |receiver| is null on failure. |
41 Connect(NetAddress remote_addr) => (NetworkError result, | 40 Connect(NetAddress remote_addr) => (NetworkError result, NetAddress? local_add
r, UDPSocketReceiver&? receiver); |
42 NetAddress? local_addr, | |
43 UDPSocketReceiver&? receiver); | |
44 | 41 |
45 // Sets the OS send buffer size (in bytes) for the socket. The socket must be | 42 // Sets the OS send buffer size (in bytes) for the socket. The socket must be |
46 // bound or connected. | 43 // bound or connected. |
47 SetSendBufferSize(uint32 size) => (NetworkError result); | 44 SetSendBufferSize(uint32 size) => (NetworkError result); |
48 | 45 |
49 // Sets the OS receive buffer size (in bytes) for the socket. The socket must | 46 // Sets the OS receive buffer size (in bytes) for the socket. The socket must |
50 // be bound or connected. | 47 // be bound or connected. |
51 SetReceiveBufferSize(uint32 size) => (NetworkError result); | 48 SetReceiveBufferSize(uint32 size) => (NetworkError result); |
52 | 49 |
53 // Negotiates the maximum number of pending SendTo() requests. If | 50 // Negotiates the maximum number of pending SendTo() requests. If |
54 // |requested_size| is set to 0, this method queries the current settings. | 51 // |requested_size| is set to 0, this method queries the current settings. |
55 // | 52 // |
56 // The service stores SendTo() requests in a queue while they are waiting to | 53 // The service stores SendTo() requests in a queue while they are waiting to |
57 // be executed (i.e., while they are waiting to be placed in the OS send | 54 // be executed (i.e., while they are waiting to be placed in the OS send |
58 // buffer and sent out). This method negotiates how many requests (not bytes) | 55 // buffer and sent out). This method negotiates how many requests (not bytes) |
59 // this queue is able to store. If the queue is full, the service fails new | 56 // this queue is able to store. If the queue is full, the service fails new |
60 // requests directly with error code ERR_INSUFFICIENT_RESOURCES and discards | 57 // requests directly with error code ERR_INSUFFICIENT_RESOURCES and discards |
61 // those datagrams. If the client wants to avoid such failures, it needs to | 58 // those datagrams. If the client wants to avoid such failures, it needs to |
62 // keep track of how many SendTo() calls are pending and make sure the number | 59 // keep track of how many SendTo() calls are pending and make sure the number |
63 // doesn't exceed the result of this method. | 60 // doesn't exceed the result of this method. |
64 NegotiateMaxPendingSendRequests(uint32 requested_size) | 61 NegotiateMaxPendingSendRequests(uint32 requested_size) => (uint32 actual_size)
; |
65 => (uint32 actual_size); | |
66 | 62 |
67 // Notifies that the receiver is ready to accept |number| of datagrams. | 63 // Notifies that the receiver is ready to accept |number| of datagrams. |
68 // Correspondingly, OnReceived() of the UDPSocketReceiver interface will be | 64 // Correspondingly, OnReceived() of the UDPSocketReceiver interface will be |
69 // called |number| times (errors also count), unless the connection is closed | 65 // called |number| times (errors also count), unless the connection is closed |
70 // before that. | 66 // before that. |
71 // | 67 // |
72 // It is allowed to call this method again before the previous request is | 68 // It is allowed to call this method again before the previous request is |
73 // completely satisfied. For example: | 69 // completely satisfied. For example: |
74 // service->ReceiveMore(3); | 70 // service->ReceiveMore(3); |
75 // ... | 71 // ... |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SendTo(NetAddress? dest_addr, array<uint8> data) => (NetworkError result); | 108 SendTo(NetAddress? dest_addr, array<uint8> data) => (NetworkError result); |
113 }; | 109 }; |
114 | 110 |
115 interface UDPSocketReceiver { | 111 interface UDPSocketReceiver { |
116 // On success, |data| is non-null, |src_addr| is non-null if the socket is | 112 // 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 | 113 // 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 | 114 // bytes have been received. On failure, |result.code| is a network error |
119 // code. | 115 // code. |
120 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); | 116 OnReceived(NetworkError result, NetAddress? src_addr, array<uint8>? data); |
121 }; | 117 }; |
OLD | NEW |