OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
zra
2017/04/07 16:29:41
2017
bkonyi
2017/04/10 19:20:06
Done.
| |
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. | |
4 | |
5 part of dart.io; | |
6 | |
7 /** | |
8 * A low-level class for communicating over a TCP socket. | |
zra
2017/04/07 16:29:41
Add warnings that direct people to the asynchronou
bkonyi
2017/04/10 19:20:06
Done.
| |
9 */ | |
10 abstract class RawSynchronousSocket { | |
11 /** | |
12 * Creates a new socket connection to the host and port and returns a | |
13 * [RawSynchronousSocket]. | |
14 * | |
15 * [host] can either be a [String] or an [InternetAddress]. If [host] is a | |
16 * [String], [connect] will perform a [InternetAddress.lookup] and try | |
17 * all returned [InternetAddress]es, until connected. Unless a | |
18 * connection was established, the error from the first failing connection is | |
19 * returned. | |
20 */ | |
21 external static RawSynchronousSocket connectSync(host, int port); | |
22 | |
23 /** | |
24 * Returns the number of received and unread bytes in the socket that can be | |
25 * read. | |
26 */ | |
27 int available(); | |
28 | |
29 /** | |
30 * Closes the [RawSynchronousSocket]. | |
31 */ | |
32 void closeSync(); | |
33 | |
34 /** | |
35 * Reads into an existing [List<int>] from the socket. If [start] is present, | |
zra
2017/04/07 16:29:41
These comments should have a short one sentence de
bkonyi
2017/04/10 19:20:06
Done.
| |
36 * the bytes will be filled into [buffer] from index [start], otherwise index | |
37 * 0. If [end] is present, [end] - [start] bytes will be read into [buffer], | |
38 * otherwise up to [buffer.length]. If [end] == [start], no bytes are read. | |
39 * Returns the number of bytes read. | |
40 */ | |
41 int readIntoSync(List<int> buffer, [int start = 0, int end]); | |
42 | |
43 // TODO(bkonyi) Update description. | |
44 /** | |
45 * Blocks and waits for a response of an arbitrary number of bytes sent by the | |
46 * remote server. If [bytes] is provided, it will be used as the maximum | |
47 * number of bytes to be read. Returns the list of bytes read. | |
48 */ | |
49 List<int> readSync(int bytes); | |
50 | |
51 /** | |
52 * TODO(bkonyi) shutdown? | |
53 */ | |
54 void shutdown(SocketDirection direction); | |
55 | |
56 /** | |
57 * Writes into the socket from a [List<int>]. If [start] is present, the bytes | |
58 * will be written to the socket starting from index [start]. If [start] is | |
59 * not present, the bytes will be written starting from index 0. If [end] is | |
60 * present, the [end] - [start] bytes will be written into the socket starting | |
61 * at index [start]. If [end] is not provided, [buffer.length] elements will | |
62 * be written to the socket starting from index [start]. If [end] == [start], | |
63 * nothing happens. | |
64 */ | |
65 void writeFromSync(List<int> buffer, [int start = 0, int end]); | |
66 | |
67 /** | |
68 * Returns the port used by this socket. | |
69 */ | |
70 int get port; | |
71 | |
72 /** | |
73 * Returns the remote port connected to by this socket. | |
74 */ | |
75 int get remotePort; | |
76 | |
77 /** | |
78 * Returns the [InternetAddress] used to connect this socket. | |
79 */ | |
80 InternetAddress get address; | |
81 | |
82 /** | |
83 * Returns the remote [InternetAddress] connected to by this socket. | |
84 */ | |
85 InternetAddress get remoteAddress; | |
86 } | |
OLD | NEW |