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 // The current state of this socket as known by the API. |
| 65 // |
| 66 // This may not represent the actual underlying state of the socket; |
| 67 // however, it will be true after a successful call to |
| 68 // <code>connect()</code> and false after a <code>disconnect()</code> call. |
| 69 boolean connected; |
| 70 |
| 71 // If the underlying socket is connected, contains the IPv4/6 address of |
| 72 // the peer. |
| 73 DOMString? peerAddress; |
| 74 |
| 75 // If the underlying socket is connected, contains the port of the |
| 76 // connected peer. |
| 77 long? peerPort; |
| 78 |
| 79 // If the underlying socket is bound or connected, contains its local |
| 80 /// IPv4/6 address. |
| 81 DOMString? localAddress; |
| 82 |
| 83 // If the underlying socket is bound or connected, contains its local port. |
| 84 long? localPort; |
| 85 }; |
| 86 |
59 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); | 87 callback RecvFromCallback = void (RecvFromInfo recvFromInfo); |
60 | 88 |
61 callback SendToCallback = void (WriteInfo writeInfo); | 89 callback SendToCallback = void (WriteInfo writeInfo); |
62 | 90 |
63 callback SetKeepAliveCallback = void (boolean result); | 91 callback SetKeepAliveCallback = void (boolean result); |
64 | 92 |
65 callback SetNoDelayCallback = void (boolean result); | 93 callback SetNoDelayCallback = void (boolean result); |
66 | 94 |
| 95 callback GetInfoCallback = void (SocketInfo result); |
| 96 |
67 interface Functions { | 97 interface Functions { |
68 // Creates a socket of the specified type that will connect to the specified | 98 // Creates a socket of the specified type that will connect to the specified |
69 // remote machine. | 99 // remote machine. |
70 // |type| : The type of socket to create. Must be <code>tcp</code> or | 100 // |type| : The type of socket to create. Must be <code>tcp</code> or |
71 // <code>udp</code>. | 101 // <code>udp</code>. |
72 // |options| : The socket options. | 102 // |options| : The socket options. |
73 // |callback| : Called when the socket has been created. | 103 // |callback| : Called when the socket has been created. |
74 static void create(SocketType type, | 104 static void create(SocketType type, |
75 optional CreateOptions options, | 105 optional CreateOptions options, |
76 CreateCallback callback); | 106 CreateCallback callback); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 optional long delay, | 185 optional long delay, |
156 SetKeepAliveCallback callback); | 186 SetKeepAliveCallback callback); |
157 | 187 |
158 // Enable/disable Nagle algorithm. | 188 // Enable/disable Nagle algorithm. |
159 // |socketId| : The socketId. | 189 // |socketId| : The socketId. |
160 // |noDelay| : If true, disable Nagle algorithm. | 190 // |noDelay| : If true, disable Nagle algorithm. |
161 // |callback| : Called when the setNoDelay attempt is complete. | 191 // |callback| : Called when the setNoDelay attempt is complete. |
162 static void setNoDelay(long socketId, | 192 static void setNoDelay(long socketId, |
163 boolean noDelay, | 193 boolean noDelay, |
164 SetNoDelayCallback callback); | 194 SetNoDelayCallback callback); |
| 195 |
| 196 // Retrieve the state of the given socket. |
| 197 // |socketId| : The socketId. |
| 198 // |callback| : Called when the state is available. |
| 199 static void getInfo(long socketId, |
| 200 GetInfoCallback callback); |
165 }; | 201 }; |
166 | 202 |
167 }; | 203 }; |
OLD | NEW |