Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: mojo/services/public/interfaces/network/tcp_socket.mojom

Issue 613683006: Add TCP socket mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/services/public/interfaces/network/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 struct TCPSocketInfo {
11 NetAddress local_address;
12 NetAddress remote_address;
13 };
14
15 // Represents a TCP socket. A socket can represent either a connection to a
16 // remote host, or a local server socket waiting for incoming connections.
17 //
18 // For client connections:
19 // - Connect(), providing a pair of streams to use for data transfer.
20 // - Read and write from the streams as desired.
21 // - Close().
22 //
23 // For server connections:
24 // - Bind() to allocate a port.
25 // - Listen() to start listening for incoming connections.
26 // - For as long as you want to accept incoming connections:
27 // - Accept() to wait for and initiate a connection once one is available.
28 // - Close().
29 interface TCPSocket {
30 // Binds this connection to a local port. The TCPSocket must not be bound,
31 // listening, or connected.
32 //
33 // This function is required to initialize a server socket for using Listen(),
34 // but is optional when using Connect() to initiate a client connection.
35 Bind(NetAddress addr) => (NetworkError result, TCPSocketInfo? info);
yzshen1 2014/09/30 20:26:13 Because there is no remote address at this point y
brettw 2014/09/30 20:32:13 I changed this case to be a NetAddr? but kept the
36
37 // Starts listening on this socket for incoming connection requests. The
38 // socket must be bound and not connected.
39 //
40 // The backlog is a hint indicating the number of incoming connections that
41 // can be queued up at one time waiting for Accept(). This queuing will
42 // happen when connections are incoming faster than Accept() can be called.
43 Listen(int32 backlog) => (NetworkError result);
44
45 // Accepts a connection. The socket must be listening.
46 //
47 // This function is called to accept an incoming connection. The caller
48 // provides the streams that will be used to send and receive data on the
49 // connection.
50 //
51 // On success, the callback will be provided with the new socket that
52 // represents the connection. It will already be in a connected state and the
53 // data streams will be ready to use.
54 Accept(handle<data_pipe_consumer> send_stream,
55 handle<data_pipe_producer> receive_stream) =>
56 (NetworkError result, TCPSocket? socket, TCPSocketInfo? info);
57
58 // Connects the socket to the given address. The socket must not be listening
59 // or previously connected. Binding the socket beforehand is optional.
60 Connect(NetAddress addr,
61 handle<data_pipe_consumer> send_stream,
62 handle<data_pipe_producer> receive_stream) =>
63 (NetworkError result, TCPSocketInfo? info);
64
65 // Closes the connection or stops listening for connections, depending on
66 // whether this socket is in server or client mode. If Close() is not called,
67 // the connection will be implicitly closes when the TCPSocket has been
68 // deleted.
69 Close();
70
71 // Controls whether small writes are coalesced to make TCP segments, and
72 // instead delivers data immediately. The default value is true (coalescing
73 // enabled).
74 SetCoaleseWrites(bool coalesce);
viettrungluu 2014/09/30 20:34:41 Having a setter but no getter seems bad. Also, no
brettw 2014/09/30 20:44:15 My plan was to use the mojo versioning to add func
75 };
76
77 }
OLDNEW
« no previous file with comments | « mojo/services/public/interfaces/network/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698