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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/socket.dart
diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart
index 3424fed03a5b345752acaa4793a879744815d9f0..c55f76329926601c35359af7b8d29dd2ef3c6b9b 100644
--- a/sdk/lib/io/socket.dart
+++ b/sdk/lib/io/socket.dart
@@ -86,6 +86,24 @@ class SocketDirection {
}
/**
+ * The [SocketOption] is used as a parameter to [Socket.setOption] and
+ * [RawSocket.setOption] to set customize the behaviour of the underlying
+ * socket.
+ */
+class SocketOption {
+ /**
+ * Enable or disable no-delay on the socket. If TCP_NODELAY is enabled, the
+ * socket will not buffer data internally, but instead write each data chunk
+ * as an invidual TCP packet.
+ *
+ * TCP_NODELAY is disabled by default.
+ */
+ static const SocketOption TCP_NODELAY = const SocketOption._(0);
+ const SocketOption._(this._value);
+ final _value;
+}
+
+/**
* Events for the [RawSocket].
*/
class RawSocketEvent {
@@ -179,6 +197,14 @@ abstract class RawSocket implements Stream<RawSocketEvent> {
* to true again to receive another write event.
*/
bool writeEventsEnabled;
+
+ /**
+ * Use [setOption] to customize the [RawSocket]. See [SocketOption] for
+ * available options.
+ *
+ * Returns [true] if the option was set successfully, false otherwise.
+ */
+ bool setOption(SocketOption option, bool enabled);
}
/**
@@ -205,6 +231,15 @@ abstract class Socket implements Stream<List<int>>,
*/
void destroy();
+ /**
+ * Enable or disable no-delay on the socket. If no-delay is enabled, the
+ * socket will not buffer data internally, but instead write each data chunk
+ * as an invidual TCP packet.
+ *
+ * No-delay is disabled by default.
+ */
+ bool setNoDelay([bool enabled = true]);
+
int get port;
String get remoteHost;
int get remotePort;
« 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