OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // File-level comment to appease parser. Eventually this will not be necessary. | 5 // File-level comment to appease parser. Eventually this will not be necessary. |
6 | 6 |
7 namespace experimental.socket { | 7 namespace experimental.socket { |
8 enum SocketType { | 8 enum SocketType { |
9 tcp, | 9 tcp, |
10 udp | 10 udp |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 long resultCode; | 49 long resultCode; |
50 | 50 |
51 ArrayBuffer data; | 51 ArrayBuffer data; |
52 | 52 |
53 // The address of the remote machine. | 53 // The address of the remote machine. |
54 DOMString address; | 54 DOMString address; |
55 | 55 |
56 long port; | 56 long port; |
57 }; | 57 }; |
58 | 58 |
59 dictionary SocketInfo { | |
60 // The type of the passed socket. This will be <code>tcp</code> or | |
61 // <code>udp</code>. | |
62 SocketType socketType; | |
63 | |
64 // Whether this socket is currently connected. | |
thorogood
2012/07/27 03:46:50
Ben, I've updated the comment here. I still think
| |
65 boolean connected; | |
66 | |
67 // If this socket is connected, contains the IPv4/6 address of the peer. | |
68 DOMString? peerAddress; | |
69 | |
70 // If this socket is connected, contains the port of the connected peer. | |
71 long? peerPort; | |
72 | |
73 // If this socket is bound or connected, contains its local IPv4/6 address. | |
74 DOMString? localAddress; | |
75 | |
76 // If this socket is bound or connected, contains its local port. | |
77 long? localPort; | |
78 }; | |
79 | |
59 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); | 80 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); |
60 | 81 |
61 callback SendToCallback = void (WriteInfo writeInfo); | 82 callback SendToCallback = void (WriteInfo writeInfo); |
62 | 83 |
63 callback SetKeepAliveCallback = void (boolean result); | 84 callback SetKeepAliveCallback = void (boolean result); |
64 | 85 |
65 callback SetNoDelayCallback = void (boolean result); | 86 callback SetNoDelayCallback = void (boolean result); |
66 | 87 |
88 callback GetInfoCallback = void (SocketInfo result); | |
89 | |
67 interface Functions { | 90 interface Functions { |
68 // Creates a socket of the specified type that will connect to the specified | 91 // Creates a socket of the specified type that will connect to the specified |
69 // remote machine. | 92 // remote machine. |
70 // |type| : The type of socket to create. Must be <code>tcp</code> or | 93 // |type| : The type of socket to create. Must be <code>tcp</code> or |
71 // <code>udp</code>. | 94 // <code>udp</code>. |
72 // |options| : The socket options. | 95 // |options| : The socket options. |
73 // |callback| : Called when the socket has been created. | 96 // |callback| : Called when the socket has been created. |
74 static void create(SocketType type, | 97 static void create(SocketType type, |
75 optional CreateOptions options, | 98 optional CreateOptions options, |
76 CreateCallback callback); | 99 CreateCallback callback); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 optional long delay, | 178 optional long delay, |
156 SetKeepAliveCallback callback); | 179 SetKeepAliveCallback callback); |
157 | 180 |
158 // Enable/disable Nagle algorithm. | 181 // Enable/disable Nagle algorithm. |
159 // |socketId| : The socketId. | 182 // |socketId| : The socketId. |
160 // |noDelay| : If true, disable Nagle algorithm. | 183 // |noDelay| : If true, disable Nagle algorithm. |
161 // |callback| : Called when the setNoDelay attempt is complete. | 184 // |callback| : Called when the setNoDelay attempt is complete. |
162 static void setNoDelay(long socketId, | 185 static void setNoDelay(long socketId, |
163 boolean noDelay, | 186 boolean noDelay, |
164 SetNoDelayCallback callback); | 187 SetNoDelayCallback callback); |
188 | |
189 // Retrieve the state of the given socket. | |
190 // |socketId| : The socketId. | |
191 // |callback| : Called when the state is available. | |
192 static void getInfo(long socketId, | |
193 GetInfoCallback callback); | |
165 }; | 194 }; |
166 | 195 |
167 }; | 196 }; |
OLD | NEW |