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

Side by Side Diff: sdk/lib/io/socket.dart

Issue 12614014: Add setNoDelay method on Socket/RawSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * The RawServerSocket is a server socket, providing a stream of low-level 8 * The RawServerSocket is a server socket, providing a stream of low-level
9 * [RawSocket]s. 9 * [RawSocket]s.
10 * 10 *
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 */ 172 */
173 bool readEventsEnabled; 173 bool readEventsEnabled;
174 174
175 /** 175 /**
176 * Set or get, if the [RawSocket] should listen for [RawSocketEvent.WRITE] 176 * Set or get, if the [RawSocket] should listen for [RawSocketEvent.WRITE]
177 * events. Default is [true]. 177 * events. Default is [true].
178 * This is a one-shot listener, and writeEventsEnabled must be set 178 * This is a one-shot listener, and writeEventsEnabled must be set
179 * to true again to receive another write event. 179 * to true again to receive another write event.
180 */ 180 */
181 bool writeEventsEnabled; 181 bool writeEventsEnabled;
182
183 /**
184 * Enable or disable no-delay on the socket. If no-delay is enabled, the
185 * socket will not buffer data internally, but instead write each data chunk
186 * as an invidual TCP packet.
187 *
188 * No-delay is disabled by default.
189 */
190 bool setNoDelay([bool enabled = true]);
Søren Gjesse 2013/03/14 11:28:40 Wondering whether this should be a setter instead
182 } 191 }
183 192
184 /** 193 /**
185 * A high-level class for communicating over a TCP socket. The [Socket] exposes 194 * A high-level class for communicating over a TCP socket. The [Socket] exposes
186 * both a [Stream] and a [IOSink] interface, making it ideal for 195 * both a [Stream] and a [IOSink] interface, making it ideal for
187 * using together with other [Stream]s. 196 * using together with other [Stream]s.
188 */ 197 */
189 abstract class Socket implements Stream<List<int>>, 198 abstract class Socket implements Stream<List<int>>,
190 IOSink<Socket> { 199 IOSink<Socket> {
191 /** 200 /**
192 * Creats a new socket connection to the host and port and returns a [Future] 201 * Creats a new socket connection to the host and port and returns a [Future]
193 * that will complete with either a [RawSocket] once connected or an error 202 * that will complete with either a [RawSocket] once connected or an error
194 * if the host-lookup or connection failed. 203 * if the host-lookup or connection failed.
195 */ 204 */
196 external static Future<Socket> connect(String host, int port); 205 external static Future<Socket> connect(String host, int port);
197 206
198 /** 207 /**
199 * Destroy the socket in both directions. Calling [destroy] will make the 208 * Destroy the socket in both directions. Calling [destroy] will make the
200 * send a close event on the stream and will no longer react on data being 209 * send a close event on the stream and will no longer react on data being
201 * piped to it. 210 * piped to it.
202 * 211 *
203 * Call [close](inherited from [IOSink]) to only close the [Socket] 212 * Call [close](inherited from [IOSink]) to only close the [Socket]
204 * for sending data. 213 * for sending data.
205 */ 214 */
206 void destroy(); 215 void destroy();
207 216
217 /**
218 * Enable or disable no-delay on the socket. If no-delay is enabled, the
219 * socket will not buffer data internally, but instead write each data chunk
220 * as an invidual TCP packet.
221 *
222 * No-delay is disabled by default.
223 */
224 bool setNoDelay([bool enabled = true]);
225
208 int get port; 226 int get port;
209 String get remoteHost; 227 String get remoteHost;
210 int get remotePort; 228 int get remotePort;
211 } 229 }
212 230
213 231
214 class SocketIOException implements Exception { 232 class SocketIOException implements Exception {
215 const SocketIOException([String this.message = "", 233 const SocketIOException([String this.message = "",
216 OSError this.osError = null]); 234 OSError this.osError = null]);
217 String toString() { 235 String toString() {
218 StringBuffer sb = new StringBuffer(); 236 StringBuffer sb = new StringBuffer();
219 sb.write("SocketIOException"); 237 sb.write("SocketIOException");
220 if (!message.isEmpty) { 238 if (!message.isEmpty) {
221 sb.write(": $message"); 239 sb.write(": $message");
222 if (osError != null) { 240 if (osError != null) {
223 sb.write(" ($osError)"); 241 sb.write(" ($osError)");
224 } 242 }
225 } else if (osError != null) { 243 } else if (osError != null) {
226 sb.write(": $osError"); 244 sb.write(": $osError");
227 } 245 }
228 return sb.toString(); 246 return sb.toString();
229 } 247 }
230 final String message; 248 final String message;
231 final OSError osError; 249 final OSError osError;
232 } 250 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698