summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con/efl_net_socket_simple.eo
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ecore_con/efl_net_socket_simple.eo')
-rw-r--r--src/lib/ecore_con/efl_net_socket_simple.eo45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/ecore_con/efl_net_socket_simple.eo b/src/lib/ecore_con/efl_net_socket_simple.eo
new file mode 100644
index 0000000..b6339ac
--- /dev/null
+++ b/src/lib/ecore_con/efl_net_socket_simple.eo
@@ -0,0 +1,45 @@
1class Efl.Net.Socket.Simple (Efl.Io.Buffered_Stream, Efl.Net.Socket) {
2 [[A wrapper socket offering an easy to use, buffered I/O.
3
4 The simple socket encapsulates an actual @Efl.Net.Socket, and
5 uses it with an @Efl.Io.Buffered_Stream, which creates an input
6 @Efl.Io.Queue, an output @Efl.Io.Queue and these are linked
7 using a receiver and a sender @Efl.Io.Copier.
8
9 The idea is that unlike traditional @Efl.Net.Socket that will
10 attempt to write directly to socket and thus may take less data
11 than requested, this one will keep the pending data in its own
12 buffer, feeding to the actual socket when it
13 @Efl.Io.Writer.can_write. That makes its operation much simpler
14 as @Efl.Io.Writer.write will always take the full data -- allows
15 "write and forget", if unlimited (see
16 @Efl.Io.Buffered_Stream.max_queue_size_output).
17
18 Reading is also much simpler since received data is kept in an
19 @Efl.Io.Queue, thus its size can be queried with
20 @Efl.Io.Buffered_Stream.pending_read and read with
21 @Efl.Io.Reader.read or peeked with
22 @Efl.Io.Buffered_Stream.slice_get, then discarded with
23 @Efl.Io.Buffered_Stream.discard or
24 @Efl.Io.Buffered_Stream.clear.
25
26 Then when waiting for a complete message, just peek at its
27 contents, if not complete do nothing, if complete then either
28 @Efl.Io.Reader.read to get a copy or manipulate a read-only
29 reference from @Efl.Io.Buffered_Stream.slice_get and then
30 @Efl.Io.Buffered_Stream.discard
31
32 The actual socket is set with the constructor method
33 @Efl.Io.Buffered_Stream.inner_io.set and can be retrieved with
34 @Efl.Io.Buffered_Stream.inner_io.get, which should be used with
35 care.
36
37 @since 1.19
38 ]]
39
40 implements {
41 Efl.Io.Buffered_Stream.inner_io.set;
42 Efl.Net.Socket.address_local.get;
43 Efl.Net.Socket.address_remote.get;
44 }
45}