OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 import "mojo/services/public/interfaces/network/net_address.mojom" | |
6 import "mojo/services/public/interfaces/network/network_error.mojom" | |
7 | |
8 module mojo { | |
9 | |
10 // UDPSocket and UDPSocketClient represent a UDP socket and its client. The | |
11 // typical flow of using the interfaces is: | |
12 // - Acquire a UDPSocket interface pointer and set a UDPSocketClient instance. | |
13 // - (optional) Set options which are allowed prior to Bind(). | |
14 // - Bind the socket. | |
15 // - (optional) Set options which are allowed after Bind(). | |
16 // - Send / request to receive packets. Received packets will be delivered to | |
17 // UDPSocketClient.OnReceived(). | |
18 [Client=UDPSocketClient] | |
19 interface UDPSocket { | |
20 // Allows the socket to share the local address to which it will be bound with | |
21 // other processes. Should be called before Bind(). | |
22 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) | |
23 AllowAddressReuse() => (NetworkError result); | |
24 | |
25 // Binds the socket to the given address. | |
26 // |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 // returned in |bound_addr|. | |
29 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); | |
30 | |
31 // Sets the send buffer size (in bytes) for the socket. The socket must be | |
32 // bound. | |
33 // | |
34 // Note: This is only treated as a hint. Even if it succeeds, the service | |
35 // doesn't guarantee it will conform to the size. | |
willchan no longer on Chromium
2014/09/30 22:16:46
What does this note mean?
It's not obvious if the
| |
36 SetSendBufferSize(uint32 size) => (NetworkError result); | |
37 | |
38 // Sets the receive buffer size (in bytes) for the socket. The socket must be | |
39 // bound. | |
40 // | |
41 // 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 SetReceiveBufferSize(uint32 size) => (NetworkError result); | |
44 | |
45 // Notifies that the client is ready to accept |number| of packets. | |
46 // Correspondingly, OnReceived() of the UDPSocketClient interface will be | |
47 // called |number| times (errors also count), unless the connection is closed | |
48 // before that. The socket must be bound. | |
49 // | |
50 // It is allowed to call this method again before the previous request is | |
51 // completely satisfied. For example: | |
52 // service->ReceiveMorePackets(3); | |
53 // ... | |
54 // // OnReceived() is called. | |
55 // // OnReceived() is called. | |
56 // ... | |
57 // service->ReceiveMorePackets(3); | |
58 // // The client expects 4 more calls to OnReceived(). | |
59 ReceiveMorePackets(uint32 number); | |
60 | |
61 // Sends data to the specified destination. The socket must be bound. | |
62 // The method doesn't report the result of the operation. | |
63 SendToAndForget(NetAddress addr, uint8[] data); | |
64 | |
65 // Sends data to the specified destination. The socket must be bound. | |
66 SendTo(NetAddress addr, uint8[] data) => (NetworkError result); | |
67 }; | |
68 | |
69 interface UDPSocketClient { | |
70 // |addr| and |data| are non-NULL on success. | |
71 OnReceived(NetworkError result, NetAddress? addr, uint8[]? data); | |
72 }; | |
73 | |
74 } | |
OLD | NEW |