ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.222 by root, Thu Aug 25 03:08:48 2011 UTC vs.
Revision 1.223 by root, Thu Sep 1 04:07:18 2011 UTC

1128 1128
1129Whenever the given C<type> is used, C<push_write> will the function with 1129Whenever the given C<type> is used, C<push_write> will the function with
1130the handle object and the remaining arguments. 1130the handle object and the remaining arguments.
1131 1131
1132The function is supposed to return a single octet string that will be 1132The function is supposed to return a single octet string that will be
1133appended to the write buffer, so you cna mentally treat this function as a 1133appended to the write buffer, so you can mentally treat this function as a
1134"arguments to on-the-wire-format" converter. 1134"arguments to on-the-wire-format" converter.
1135 1135
1136Example: implement a custom write type C<join> that joins the remaining 1136Example: implement a custom write type C<join> that joins the remaining
1137arguments using the first one. 1137arguments using the first one.
1138 1138
2204Probably because your C<on_error> callback is being called instead: When 2204Probably because your C<on_error> callback is being called instead: When
2205you have outstanding requests in your read queue, then an EOF is 2205you have outstanding requests in your read queue, then an EOF is
2206considered an error as you clearly expected some data. 2206considered an error as you clearly expected some data.
2207 2207
2208To avoid this, make sure you have an empty read queue whenever your handle 2208To avoid this, make sure you have an empty read queue whenever your handle
2209is supposed to be "idle" (i.e. connection closes are O.K.). You cna set 2209is supposed to be "idle" (i.e. connection closes are O.K.). You can set
2210an C<on_read> handler that simply pushes the first read requests in the 2210an C<on_read> handler that simply pushes the first read requests in the
2211queue. 2211queue.
2212 2212
2213See also the next question, which explains this in a bit more detail. 2213See also the next question, which explains this in a bit more detail.
2214 2214
2245some data and raises the C<EPIPE> error when the connction is dropped 2245some data and raises the C<EPIPE> error when the connction is dropped
2246unexpectedly. 2246unexpectedly.
2247 2247
2248The second variant is a protocol where the client can drop the connection 2248The second variant is a protocol where the client can drop the connection
2249at any time. For TCP, this means that the server machine may run out of 2249at any time. For TCP, this means that the server machine may run out of
2250sockets easier, and in general, it means you cnanot distinguish a protocl 2250sockets easier, and in general, it means you cannot distinguish a protocl
2251failure/client crash from a normal connection close. Nevertheless, these 2251failure/client crash from a normal connection close. Nevertheless, these
2252kinds of protocols are common (and sometimes even the best solution to the 2252kinds of protocols are common (and sometimes even the best solution to the
2253problem). 2253problem).
2254 2254
2255Having an outstanding read request at all times is possible if you ignore 2255Having an outstanding read request at all times is possible if you ignore

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines