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

Side by Side Diff: runtime/bin/tls_socket.dart

Issue 10704159: Start adding TLS (SSL) sockets to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tls_socket.dart back. This should not be compared to socket.dart. Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface ServerSocket default _ServerSocket { 5 interface TlsSocket extends Socket, Hashable default _TlsSocket {
6 /** 6 /**
7 * Constructs a new server socket, binds it to a given address and port, 7 * Constructs a new secure socket and connect it to the given
8 * and listens on it.
9 */
10 ServerSocket(String bindAddress, int port, int backlog);
11
12 /**
13 * The connection handler gets called when there is a new incoming
14 * connection on the socket.
15 */
16 void set onConnection(void callback(Socket connection));
17
18 /**
19 * The error handler gets called when a socket error occurs.
20 */
21 void set onError(void callback(e));
22
23 /**
24 * Returns the port used by this socket.
25 */
26 int get port();
27
28 /**
29 * Closes the socket.
30 */
31 void close();
32 }
33
34
35 interface Socket extends Hashable default _Socket {
36 /**
37 * Constructs a new socket and initiate connecting it to the given
38 * host on the given port. The returned socket is not yet connected 8 * host on the given port. The returned socket is not yet connected
39 * but ready for registration of callbacks. 9 * but ready for registration of callbacks.
40 */ 10 */
41 Socket(String host, int port); 11 TlsSocket(String host, int port);
42 12
Søren Gjesse 2012/07/31 09:07:15 As TlsSocket extends Socket is there any need to d
Bill Hesse 2012/08/08 17:00:05 No there is not. Fixed.
43 /** 13 /**
44 * Returns the number of received and non-read bytes in the socket that 14 * Returns the number of received and non-read bytes in the socket that
45 * can be read. 15 * can be read.
46 */ 16 */
47 int available(); 17 int available();
48 18
49 /** 19 /**
50 * Reads up to [count] bytes of data from the socket and stores them into 20 * Reads up to [count] bytes of data from the socket and stores them into
51 * buffer after buffer offset [offset]. The number of successfully read 21 * buffer after buffer offset [offset]. The number of successfully read
52 * bytes is returned. This function is non-blocking and will only read data 22 * bytes is returned. This function is non-blocking and will only read data
(...skipping 14 matching lines...) Expand all
67 * succeeded. 37 * succeeded.
68 */ 38 */
69 void set onConnect(void callback()); 39 void set onConnect(void callback());
70 40
71 /** 41 /**
72 * The data handler gets called when data becomes available at the socket. 42 * The data handler gets called when data becomes available at the socket.
73 */ 43 */
74 void set onData(void callback()); 44 void set onData(void callback());
75 45
76 /** 46 /**
77 * The write handler gets called once when the socket becomes 47 * The write handler gets called when the socket becomes available for
78 * available for writing. Then the handler is automatically reset to null. 48 * writing.
79 * This handler is mainly used when writeList has reported an incomplete
80 * write, to schedule writing the remaining data to the socket.
81 */ 49 */
82 void set onWrite(void callback()); 50 void set onWrite(void callback());
83 51
84 /** 52 /**
85 * The close handler gets called when a the last byte have been read 53 * The close handler gets called when a the last byte have been read
86 * from a socket. At this point the socket might still be open for 54 * from a socket. At this point the socket might still be open for
87 * writing for sending more data. 55 * writing for sending more data.
88 */ 56 */
89 void set onClosed(void callback()); 57 void set onClosed(void callback());
90 58
91 /** 59 /**
92 * The error handler gets called when a socket error occurs. 60 * The error handler gets called when a socket error occurs.
93 */ 61 */
94 void set onError(void callback(e)); 62 void set onError(void callback(e));
95 63
96 /** 64 /**
97 * Returns input stream to the socket. 65 * Returns input stream to the socket.
66 * Not yet implemented.
98 */ 67 */
99 InputStream get inputStream(); 68 InputStream get inputStream();
100 69
101 /** 70 /**
102 * Returns output stream of the socket. 71 * Returns output stream of the socket.
72 * Not yet implemented.
103 */ 73 */
104 OutputStream get outputStream(); 74 OutputStream get outputStream();
105 75
106 /** 76 /**
107 * Returns the port used by this socket. 77 * Returns the port used by this socket.
108 */ 78 */
109 int get port(); 79 int get port();
110 80
111 /** 81 /**
112 * Returns the remote port connected to by this socket. 82 * Returns the remote port connected to by this socket.
113 */ 83 */
114 int get remotePort(); 84 int get remotePort();
115 85
116 /** 86 /**
117 * Returns the remote host connected to by this socket. 87 * Returns the remote host connected to by this socket.
118 */ 88 */
119 String get remoteHost(); 89 String get remoteHost();
120 90
121 /** 91 /**
122 * Closes the socket. Calling [close] will never throw an exception 92 * Closes the socket. Calling [close] will never throw an exception
123 * and calling it several times is supported. If [halfClose] is true 93 * and calling it several times is supported. If [halfClose] is true
124 * the socket will only be closed for writing and it might still be 94 * the socket will only be closed for writing and it might still be
125 * possible to read data. Calling [close] will not trigger a call to 95 * possible to read data. Calling [close] will not trigger a call to
126 * [onClosed]. 96 * [onClosed].
127 */ 97 */
128 void close([bool halfClose]); 98 void close([bool halfClose = false]);
129 99
130 /** 100 /**
131 * Socket is hashable. 101 * Socket is hashable.
132 */ 102 */
133 int hashCode(); 103 int hashCode();
134 } 104 }
135
136
137 class SocketIOException implements Exception {
138 const SocketIOException([String this.message = "",
139 OSError this.osError = null]);
140 String toString() {
141 StringBuffer sb = new StringBuffer();
142 sb.add("SocketIOException");
143 if (!message.isEmpty()) {
144 sb.add(": $message");
145 if (osError != null) {
146 sb.add(" ($osError)");
147 }
148 } else if (osError != null) {
149 sb.add(": $osError");
150 }
151 return sb.toString();
152 }
153 final String message;
154 final OSError osError;
155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698