Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[unix] make the unix-socket backend work again

  • Loading branch information...
commit 3d886b5895cb8c597cb76d27cea0de062526be0f 1 parent ea28ab5
Anil Madhavapeddy authored June 09, 2012
3  assemble.sh
@@ -93,7 +93,6 @@ function assemble_bin {
93 93
 assemble_syntax
94 94
 assemble_xen
95 95
 assemble_unix "direct"
96  
-#assemble_unix "socket"
97  
-#assemble_node
  96
+assemble_unix "socket"
98 97
 assemble_scripts
99 98
 assemble_bin
12  lib/Makefile
@@ -15,19 +15,13 @@ ifeq ($(OS) $(ARCH),linux x86_64)
15 15
 XEN_BUILD=xen
16 16
 endif
17 17
 
18  
-ifeq ($(NODE),)
19  
-NODE_BUILD=
20  
-else
21  
-NODE_BUILD=
22  
-endif
23  
-
24  
-UNIX_BUILD= unix-direct
  18
+UNIX_BUILD= unix-direct unix-socket
25 19
 
26  
-all: $(XEN_BUILD) $(NODE_BUILD) $(UNIX_BUILD)
  20
+all: $(XEN_BUILD) $(UNIX_BUILD)
27 21
 	@ :
28 22
 
29 23
 doc:
30  
-	for spec in $(XEN_BUILD) $(NODE_BUILD) $(UNIX_BUILD); do \
  24
+	for spec in $(XEN_BUILD) $(UNIX_BUILD); do \
31 25
 	  SPEC=$$spec ocamlbuild $(OFLOAGS) $(JOBS) doc.otarget; \
32 26
 	done
33 27
 
198  lib/net/socket/channel.ml
@@ -31,51 +31,58 @@ module Make(Flow:FLOW) :
31 31
 
32 32
   type t = {
33 33
     flow: flow;
34  
-    mutable ibuf: Bitstring.t;
35  
-    mutable obuf: Bitstring.t list;
  34
+    mutable ibuf: OS.Io_page.t option; (* Queue of incoming buf *)
  35
+    mutable obufq: OS.Io_page.t list;  (* Queue of completed writebuf *)
  36
+    mutable obuf: OS.Io_page.t option; (* Active write buffer *)
  37
+    mutable opos: int;                 (* Position in active write buffer *)
36 38
     abort_t: unit Lwt.t;
37 39
     abort_u: unit Lwt.u;
38 40
   }
39 41
 
  42
+  exception Closed
  43
+
40 44
   let create flow =
41  
-    let ibuf = "",0,0 in
42  
-    let obuf = [] in
  45
+    let ibuf = None in
  46
+    let obufq = [] in
  47
+    let obuf = None in
  48
+    let opos = 0 in
43 49
     let abort_t, abort_u = Lwt.task () in
44  
-    { ibuf; obuf; flow; abort_t; abort_u }
  50
+    { ibuf; obuf; flow; obufq; opos; abort_t; abort_u }
45 51
 
46 52
   let ibuf_refill t = 
47 53
     match_lwt Flow.read t.flow with
48 54
     |Some buf ->
49  
-      t.ibuf <- buf;
  55
+      t.ibuf <- Some buf;
50 56
       return ()
51 57
     |None ->
52 58
       fail Closed
53 59
 
  60
+  let rec get_ibuf t =
  61
+    match t.ibuf with
  62
+    |None -> ibuf_refill t >> get_ibuf t
  63
+    |Some buf when Cstruct.len buf = 0 -> ibuf_refill t >> get_ibuf t
  64
+    |Some buf -> return buf
  65
+
54 66
   (* Read one character from the input channel *)
55  
-  let rec read_char t =
56  
-    bitmatch t.ibuf with
57  
-    | { c:8; rest:-1:bitstring } ->
58  
-        t.ibuf <- rest;
59  
-        return (Char.chr c)
60  
-    | { rest:-1:bitstring } when Bitstring.bitstring_length rest = 0 ->
61  
-        ibuf_refill t >>
62  
-        read_char t
  67
+  let read_char t =
  68
+    lwt buf = get_ibuf t in
  69
+    let c = Cstruct.get_char buf 0 in
  70
+    t.ibuf <- Some (Cstruct.shift buf 1);
  71
+    return c
63 72
 
64 73
   (* Read up to len characters from the input channel
65 74
      and at most a full view. If not specified, read all *)
66 75
   let read_some ?len t =
67  
-    lwt () = if Bitstring.bitstring_length t.ibuf = 0 then
68  
-      ibuf_refill t else return () in
69  
-    let avail = Bitstring.bitstring_length t.ibuf in
70  
-    let len = match len with |Some len -> len * 8 |None -> avail in
  76
+    lwt buf = get_ibuf t in
  77
+    let avail = Cstruct.len buf in
  78
+    let len = match len with |Some len -> len |None -> avail in
71 79
     if len < avail then begin 
72  
-      let r = Bitstring.subbitstring t.ibuf 0 len in
73  
-      t.ibuf <- Bitstring.subbitstring t.ibuf len (avail-len);
74  
-      return r
  80
+      let hd,tl = Cstruct.split buf len in
  81
+      t.ibuf <- Some tl;
  82
+      return hd
75 83
     end else begin 
76  
-      let r = t.ibuf in
77  
-      t.ibuf <- "",0,0;
78  
-      return r
  84
+      t.ibuf <- None;
  85
+      return buf
79 86
     end
80 87
     
81 88
   (* Read up to len characters from the input channel as a 
@@ -91,77 +98,110 @@ module Make(Flow:FLOW) :
91 98
  
92 99
   (* Read until a character is found *)
93 100
   let read_until t ch =
94  
-    lwt () = if Bitstring.bitstring_length t.ibuf = 0 then
95  
-      ibuf_refill t else return () in
96  
-    try_lwt
97  
-      let buf,off,len = t.ibuf in
98  
-      let idx = (String.index_between buf (off/8) ((off+len)/8) ch) * 8 in
99  
-      let rlen = idx - off in
100  
-      (bitmatch t.ibuf with
101  
-      | { _:8; rest:-1:bitstring } when rlen = 0 ->
102  
-          t.ibuf <- rest;
103  
-          return (true, Bitstring.empty_bitstring)
104  
-      | { r:rlen:bitstring; _:8; rest:-1:bitstring } ->
105  
-          t.ibuf <- rest;
106  
-          return (true, r)
107  
-      | { _ } ->
108  
-          printf "Flow: unexpected bitmatch failure in read_until\n%!";
109  
-          exit 1
110  
-      )
111  
-    with Not_found -> begin
112  
-      let r = t.ibuf in
113  
-      t.ibuf <- "",0,0; 
114  
-      return (false,r)
115  
-    end
  101
+    lwt buf = get_ibuf t in
  102
+    let len = Cstruct.len buf in
  103
+    let rec scan off =
  104
+      if off = len then None else begin
  105
+        if Cstruct.get_char buf off = ch then
  106
+          Some off else scan (off+1)
  107
+      end
  108
+    in
  109
+    match scan 0 with
  110
+    |None -> (* not found, return what we have until EOF *)
  111
+      t.ibuf <- None;
  112
+      return (false, buf)
  113
+    |Some off -> (* found, so split the buffer *)
  114
+      let hd = Cstruct.sub_buffer buf 0 off in
  115
+      t.ibuf <- Some (Cstruct.shift buf (off+1));
  116
+      return (true, hd)
116 117
 
117 118
   (* This reads a line of input, which is terminated either by a CRLF
118 119
      sequence, or the end of the channel (which counts as a line).
119 120
      @return Returns a stream of views that terminates at EOF.
120 121
      @raise Closed to signify EOF  *)
121  
-  let read_crlf t =
  122
+  let read_line t =
122 123
     let rec get acc =
123 124
       match_lwt read_until t '\n' with
124 125
       |(false, v) ->
125 126
         get (v :: acc)
126 127
       |(true, v) -> begin
127 128
         (* chop the CR if present *)
128  
-        let vlen = Bitstring.bitstring_length v in
129  
-        let v = bitmatch v with
130  
-          | { rest:vlen-8:bitstring; 13:8 } when vlen >= 8 -> rest
131  
-          | { _ } -> v in
  129
+        let vlen = Cstruct.len v in
  130
+        let v =
  131
+         if vlen > 0 && (Cstruct.get_char v (vlen-1) = '\r') then
  132
+           Cstruct.sub v 0 (vlen-1) else v
  133
+        in
132 134
         return (v :: acc) 
133 135
       end
134 136
     in
135  
-    lwt res = get [] >|= List.rev in
136  
-    return (Bitstring.concat res)
  137
+    get [] >|= List.rev
137 138
     
138 139
   (* Output functions *)
139 140
 
140  
-  let rec flush t =
141  
-    let l = List.rev t.obuf in
142  
-    lwt res = Flow.writev t.flow l in
143  
-    t.obuf <- [res];
144  
-    if Bitstring.bitstring_length res > 0 then
145  
-      flush t
146  
-    else
147  
-      return ()
148  
-
149  
-  (* Stonkingly inefficient *)
  141
+  let alloc_obuf t =
  142
+    let buf = OS.Io_page.get () in
  143
+    t.obuf <- Some buf;
  144
+    t.opos <- 0;
  145
+    buf
  146
+
  147
+  (* Queue the active write buffer onto the write queue, resizing the
  148
+   * view if necessary to the correct size. *)
  149
+  let queue_obuf t =
  150
+    match t.obuf with
  151
+    |None -> ()
  152
+    |Some buf when Cstruct.len buf = t.opos -> (* obuf is full *)
  153
+      t.obufq <- buf :: t.obufq;
  154
+      t.obuf <- None
  155
+    |Some buf when t.opos = 0 -> (* obuf wasnt ever used, so discard *)
  156
+      t.obuf <- None
  157
+    |Some buf -> (* partially filled obuf, so resize *)
  158
+      let buf = Cstruct.sub buf 0 t.opos in
  159
+      t.obufq <- buf :: t.obufq;
  160
+      t.obuf <- None
  161
+
  162
+  (* Get an active output buffer, which will allocate it if needed.
  163
+   * The position to write into is stored in t.opos *)
  164
+  let get_obuf t =
  165
+    match t.obuf with
  166
+    |None -> alloc_obuf t
  167
+    |Some buf when Cstruct.len buf = t.opos -> queue_obuf t; alloc_obuf t
  168
+    |Some buf -> buf
  169
+
  170
+  (* Non-blocking character write, since Io page allocation never blocks.
  171
+   * That may change in the future... *)
150 172
   let write_char t ch =
151  
-    t.obuf <- ((String.make 1 ch),0,8) :: t.obuf;
152  
-    return ()
153  
-
154  
-  let write_bitstring t buf =
155  
-    t.obuf <- buf :: t.obuf;
156  
-    return ()
157  
-
158  
-  let write_string t buf =
159  
-    write_bitstring t (Bitstring.bitstring_of_string buf)
  173
+    let buf = get_obuf t in
  174
+    Cstruct.set_char buf t.opos ch;
  175
+    t.opos <- t.opos + 1
  176
+
  177
+  (* This is zero copy; flush current IO page and queue up the incoming
  178
+   * buffer directly. *)
  179
+  let write_buffer t buf =
  180
+    queue_obuf t;
  181
+    t.obufq <- buf :: t.obufq
  182
+
  183
+  let rec write_string t s off len =
  184
+    let buf = get_obuf t in
  185
+    let avail = Cstruct.len buf - t.opos in 
  186
+    if avail < len then begin
  187
+      Cstruct.set_buffer s off buf t.opos avail;
  188
+      t.opos <- t.opos + avail;
  189
+      write_string t s (off+avail) (len-avail)
  190
+    end else begin
  191
+      Cstruct.set_buffer s off buf t.opos len;
  192
+      t.opos <- t.opos + len
  193
+    end
160 194
 
161 195
   let write_line t buf =
162  
-    write_string t buf >>
  196
+    write_string t buf 0 (String.length buf);
163 197
     write_char t '\n'
164 198
 
  199
+  let rec flush t =
  200
+    queue_obuf t;
  201
+    let l = List.rev t.obufq in
  202
+    t.obufq <- [];
  203
+    Flow.writev t.flow l
  204
+ 
165 205
   let close t =
166 206
     flush t >>
167 207
     Flow.close t.flow
@@ -197,9 +237,9 @@ let read_stream ?len = function
197 237
   | TCPv4 t -> TCPv4.read_stream ?len t
198 238
   | Pipe t -> Pipe.read_stream ?len t
199 239
 
200  
-let read_crlf = function
201  
-  | TCPv4 t -> TCPv4.read_crlf t
202  
-  | Pipe t -> Pipe.read_crlf t
  240
+let read_line = function
  241
+  | TCPv4 t -> TCPv4.read_line t
  242
+  | Pipe t -> Pipe.read_line t
203 243
 
204 244
 let write_char = function
205 245
   | TCPv4 t -> TCPv4.write_char t
@@ -209,9 +249,9 @@ let write_string = function
209 249
   | TCPv4 t -> TCPv4.write_string t
210 250
   | Pipe t -> Pipe.write_string t
211 251
 
212  
-let write_bitstring = function
213  
-  | TCPv4 t -> TCPv4.write_bitstring t
214  
-  | Pipe t -> Pipe.write_bitstring t
  252
+let write_buffer = function
  253
+  | TCPv4 t -> TCPv4.write_buffer t
  254
+  | Pipe t -> Pipe.write_buffer t
215 255
 
216 256
 let write_line = function
217 257
   | TCPv4 t -> TCPv4.write_line t
17  lib/net/socket/channel.mli
@@ -29,15 +29,15 @@ module Pipe : CHANNEL with
29 29
 type t
30 30
 
31 31
 val read_char: t -> char Lwt.t
32  
-val read_some: ?len:int -> t -> Bitstring.t Lwt.t
33  
-val read_until: t -> char -> (bool * Bitstring.t) Lwt.t
34  
-val read_stream: ?len:int -> t -> Bitstring.t Lwt_stream.t
35  
-val read_crlf: t -> Bitstring.t Lwt.t
  32
+val read_some: ?len:int -> t -> OS.Io_page.t Lwt.t
  33
+val read_until: t -> char -> (bool * OS.Io_page.t) Lwt.t
  34
+val read_stream: ?len:int -> t -> OS.Io_page.t Lwt_stream.t
  35
+val read_line: t -> OS.Io_page.t list Lwt.t
36 36
 
37  
-val write_char : t -> char -> unit Lwt.t
38  
-val write_string : t -> string -> unit Lwt.t
39  
-val write_bitstring : t -> Bitstring.t -> unit Lwt.t
40  
-val write_line : t -> string -> unit Lwt.t
  37
+val write_char : t -> char -> unit 
  38
+val write_string : t -> string -> int -> int -> unit
  39
+val write_buffer : t -> OS.Io_page.t -> unit
  40
+val write_line : t -> string -> unit
41 41
 
42 42
 val flush : t -> unit Lwt.t
43 43
 val close : t -> unit Lwt.t
@@ -53,4 +53,3 @@ val listen :
53 53
    | `Pipe of peer_uid * (peer_uid -> t -> unit Lwt.t)
54 54
    | `TCPv4 of ipv4_src * (ipv4_dst -> t -> unit Lwt.t)
55 55
   ] -> unit Lwt.t
56  
-
17  lib/net/socket/datagram.ml
@@ -29,16 +29,15 @@ module UDPv4 = struct
29 29
   type src = ipv4_addr option * int
30 30
   type dst = ipv4_addr * int
31 31
 
32  
-  type msg = Bitstring.t
  32
+  type msg = OS.Io_page.t
33 33
 
34  
-  let rec send mgr ?src (dstaddr, dstport) req =
35  
-    let (buf,off,len) = req in
  34
+  let rec send mgr ?src (dstaddr, dstport) buf =
36 35
     lwt fd = match src with
37 36
       |None -> return (Manager.get_udpv4 mgr)
38 37
       |Some src -> Manager.get_udpv4_listener mgr src
39 38
     in
40  
-    let off = off / 8 in
41  
-    let len = len / 8 in
  39
+    let off = Cstruct.base_offset buf in
  40
+    let len = Cstruct.len buf in
42 41
     let dst = (ipv4_addr_to_uint32 dstaddr, dstport) in
43 42
     match R.udpv4_sendto fd buf off len dst with
44 43
     |R.OK len' ->
@@ -48,18 +47,18 @@ module UDPv4 = struct
48 47
         return ()
49 48
     |R.Retry -> 
50 49
       Activations.write fd >>
51  
-      send mgr (dstaddr, dstport) req
  50
+      send mgr (dstaddr, dstport) buf
52 51
     |R.Err err -> fail (Error err)
53 52
 
54 53
   let recv mgr (addr,port) fn =
55 54
     lwt lfd = Manager.get_udpv4_listener mgr (addr,port) in
56  
-    let buf = String.create 4096 in
  55
+    let buf = OS.Io_page.get () in
57 56
     let rec listen () =
58  
-      match R.udpv4_recvfrom lfd buf 0 (String.length buf) with
  57
+      match R.udpv4_recvfrom lfd buf 0 (Cstruct.len buf) with
59 58
       |R.OK (frm_addr, frm_port, len) ->
60 59
         let frm_addr = ipv4_addr_of_uint32 frm_addr in
61 60
         let dst = (frm_addr, frm_port) in
62  
-        let req = (buf,0,(len * 8)) in
  61
+        let req = Cstruct.sub buf 0 len in
63 62
         (* Be careful to catch an exception here, as otherwise
64 63
            ignore_result may raise it at some other random point *)
65 64
         Lwt.ignore_result (
2  lib/net/socket/datagram.mli
@@ -18,5 +18,5 @@ module UDPv4 : Nettypes.DATAGRAM with
18 18
       type mgr = Manager.t
19 19
   and type src = Nettypes.ipv4_src
20 20
   and type dst = Nettypes.ipv4_dst
21  
-  and type msg = Bitstring.t
  21
+  and type msg = OS.Io_page.t
22 22
 
59  lib/net/socket/flow.ml
@@ -100,43 +100,39 @@ let listen_tcpv4 addr port fn =
100 100
     fail (Listen_error "listen retry") (* Listen never blocks *)
101 101
 
102 102
 (* Read a buffer off the wire *)
103  
-let rec read_buf t istr off len =
104  
-  match R.read t.fd istr off len with
  103
+let rec read_buf t buf off len =
  104
+  match R.read t.fd buf off len with
105 105
   |R.Retry ->
106 106
     Activations.read t.fd >>
107  
-    read_buf t istr off len
  107
+    read_buf t buf off len
108 108
   |R.OK r -> return r
109 109
   |R.Err e -> fail (Read_error e)
110 110
 
111  
-let rec write_buf t (buf,off,len) =
112  
-  match R.write t.fd buf (off/8) (len/8) with 
  111
+let rec write_buf t buf =
  112
+  match R.write t.fd buf 0 (Cstruct.len buf) with
113 113
   |R.Retry ->
114 114
     Activations.write t.fd >>
115  
-    write_buf t (buf,off,len)
  115
+    write_buf t buf
116 116
   |R.OK amt ->
117  
-    let amt = amt * 8 in
  117
+    let len = Cstruct.len buf in
118 118
     if amt = len then return ()
119  
-    else write_buf t (buf,(off+amt),(len-amt))
  119
+    else write_buf t (Cstruct.shift buf amt)
120 120
   |R.Err e -> fail (Write_error e)
121 121
 
122 122
 let read t =
123  
-  let buf = String.create 4096 in
124  
-  lwt len = read_buf t buf 0 (String.length buf) in
  123
+  let buf = OS.Io_page.get () in
  124
+  lwt len = read_buf t buf 0 (Cstruct.len buf) in
125 125
   match len with
126 126
   |0 -> return None
127  
-  |len -> return (Some (buf, 0, (len * 8)))
  127
+  |len -> return (Some (Cstruct.sub buf 0 len))
128 128
 
129 129
 let write t bs =
130 130
   write_buf t bs
131 131
 
132  
-(* For now this is the slow "just concat bitstrings"
133  
-   but it should be rewritten to block intelligently based
134  
-   on the available write space XXX TODO *)
135  
-let writev t views =
136  
-  let view = Bitstring.concat views in
137  
-  write t view >>
138  
-  return Bitstring.empty_bitstring
139  
-
  132
+(* TODO use writev: but do a set of writes for now *)
  133
+let writev t pages =
  134
+  Lwt_list.iter_s (write t) pages
  135
+ 
140 136
 module TCPv4 = struct
141 137
   type t = [`tcpv4] fdwrap
142 138
   type mgr = Manager.t
@@ -181,19 +177,26 @@ module Pipe = struct
181 177
   type src = int (* process pid *)
182 178
   type dst = int (* process pid *)
183 179
 
184  
-  type msg = Bitstring.t
  180
+  type msg = OS.Io_page.t
185 181
 
186 182
   let read (rd,_) = read rd
187 183
   let write (_,wr) view = write wr view
188 184
 
189  
-  (* For now this is the slow "just concat bitstrings"
190  
-     but it should be rewritten to block intelligently based
191  
-     on the available write space XXX TODO *)
192  
-  let writev t views =
193  
-    let view = Bitstring.concat views in
194  
-    write t view >>
195  
-    return Bitstring.empty_bitstring
196  
-
  185
+  let writev t pages =
  186
+    match pages with
  187
+    |[] -> return ()
  188
+    |[page] -> write t page
  189
+    |pages ->
  190
+      let page = Io_page.get () in
  191
+      let off = ref 0 in
  192
+      List.iter (fun p ->
  193
+        let len = Cstruct.len p in
  194
+        Cstruct.blit_buffer p 0 page !off len;
  195
+        off := !off + len;
  196
+      ) pages;
  197
+      let v = Cstruct.sub page 0 !off in
  198
+      write t v
  199
+ 
197 200
   let close (rd,wr) = close rd <&> (close wr)
198 201
 
199 202
   let listen mgr src fn =
5  lib/net/socket/flow.mli
@@ -27,8 +27,9 @@ module Pipe : FLOW with
27 27
   and type dst = peer_uid
28 28
 
29 29
 type t
30  
-val read: t -> Bitstring.t option Lwt.t
31  
-val write: t -> Bitstring.t -> unit Lwt.t
  30
+val read: t -> OS.Io_page.t option Lwt.t
  31
+val write: t -> OS.Io_page.t -> unit Lwt.t
  32
+val writev: t -> OS.Io_page.t list -> unit Lwt.t
32 33
 val close: t -> unit Lwt.t
33 34
 
34 35
 val connect :
3  lib/net/socket/manager.mli
@@ -28,9 +28,6 @@ val local_peers : 'a -> OS.Socket.uid list
28 28
 val local_uid : 'a -> OS.Socket.uid
29 29
 val connect_to_peer : t -> peer_uid -> [ `domain ] OS.Socket.fd option Lwt.t
30 30
 
31  
-val intercept : interface -> (string -> string * int * int  -> unit Lwt.t) -> unit 
32  
-val send_raw: t -> string -> (Bitstring.t list)  -> unit Lwt.t
33  
-
34 31
 val listen_to_peers : t -> (int -> [< `rd_pipe | `wr_pipe ] OS.Socket.fd * [< `rd_pipe | `wr_pipe ] OS.Socket.fd -> unit Lwt.t) -> unit Lwt.t
35 32
 val connect : t -> peer_uid -> ([ `rd_pipe ] OS.Socket.fd * [ `wr_pipe ] OS.Socket.fd -> 'a Lwt.t) -> 'a Lwt.t
36 33
 val get_udpv4 : t -> [ `udpv4 ] OS.Socket.fd
29  lib/net/socket/nettypes.ml
@@ -50,6 +50,11 @@ let ethernet_mac_broadcast = String.make 6 '\255'
50 50
 type ipv4_addr = int32
51 51
 
52 52
 let ipv4_addr_of_tuple (a,b,c,d) =
  53
+  let in_range x = Int32.zero <= x && x <= 255l in
  54
+  assert (in_range a);
  55
+  assert (in_range b);
  56
+  assert (in_range c);
  57
+  assert (in_range d);
53 58
    let (+) = Int32.add in
54 59
    (Int32.shift_left a 24) +
55 60
    (Int32.shift_left b 16) + 
@@ -102,9 +107,9 @@ module type FLOW = sig
102 107
   type dst
103 108
 
104 109
   (* Read and write to a flow *)
105  
-  val read: t -> Bitstring.t option Lwt.t
106  
-  val write: t -> Bitstring.t -> unit Lwt.t
107  
-  val writev: t -> Bitstring.t list -> Bitstring.t Lwt.t
  110
+  val read: t -> OS.Io_page.t option Lwt.t
  111
+  val write: t -> OS.Io_page.t -> unit Lwt.t
  112
+  val writev: t -> OS.Io_page.t list -> unit Lwt.t
108 113
 
109 114
   val close: t -> unit Lwt.t
110 115
 
@@ -137,15 +142,15 @@ module type CHANNEL = sig
137 142
   type dst
138 143
 
139 144
   val read_char: t -> char Lwt.t
140  
-  val read_until: t -> char -> (bool * Bitstring.t) Lwt.t
141  
-  val read_some: ?len:int -> t -> Bitstring.t Lwt.t
142  
-  val read_stream: ?len:int -> t -> Bitstring.t Lwt_stream.t
143  
-  val read_crlf: t -> Bitstring.t Lwt.t
144  
-
145  
-  val write_char : t -> char -> unit Lwt.t
146  
-  val write_string : t -> string -> unit Lwt.t
147  
-  val write_bitstring : t -> Bitstring.t -> unit Lwt.t
148  
-  val write_line : t -> string -> unit Lwt.t
  145
+  val read_until: t -> char -> (bool * OS.Io_page.t) Lwt.t
  146
+  val read_some: ?len:int -> t -> OS.Io_page.t Lwt.t
  147
+  val read_stream: ?len:int -> t -> OS.Io_page.t Lwt_stream.t
  148
+  val read_line: t -> OS.Io_page.t list Lwt.t
  149
+
  150
+  val write_char : t -> char -> unit
  151
+  val write_string : t -> string -> int -> int -> unit
  152
+  val write_buffer : t -> OS.Io_page.t -> unit
  153
+  val write_line : t -> string -> unit
149 154
 
150 155
   val flush : t -> unit Lwt.t
151 156
   val close : t -> unit Lwt.t
24  lib/net/socket/nettypes.mli
@@ -55,9 +55,9 @@ module type FLOW = sig
55 55
   type src
56 56
   type dst
57 57
 
58  
-  val read : t -> Bitstring.t option Lwt.t
59  
-  val write : t -> Bitstring.t -> unit Lwt.t
60  
-  val writev : t -> Bitstring.t list -> Bitstring.t Lwt.t
  58
+  val read : t -> OS.Io_page.t option Lwt.t
  59
+  val write : t -> OS.Io_page.t -> unit Lwt.t
  60
+  val writev : t -> OS.Io_page.t list -> unit Lwt.t
61 61
   val close : t -> unit Lwt.t
62 62
 
63 63
   val listen : mgr -> src -> (dst -> t -> unit Lwt.t) -> unit Lwt.t
@@ -84,15 +84,15 @@ module type CHANNEL = sig
84 84
   type dst
85 85
 
86 86
   val read_char: t -> char Lwt.t
87  
-  val read_until: t -> char -> (bool * Bitstring.t) Lwt.t
88  
-  val read_some: ?len:int -> t -> Bitstring.t Lwt.t
89  
-  val read_stream: ?len: int -> t -> Bitstring.t Lwt_stream.t
90  
-  val read_crlf: t -> Bitstring.t Lwt.t
91  
-
92  
-  val write_char : t -> char -> unit Lwt.t
93  
-  val write_string : t -> string -> unit Lwt.t
94  
-  val write_bitstring : t -> Bitstring.t -> unit Lwt.t
95  
-  val write_line : t -> string -> unit Lwt.t
  87
+  val read_until: t -> char -> (bool * OS.Io_page.t) Lwt.t
  88
+  val read_some: ?len:int -> t -> OS.Io_page.t Lwt.t
  89
+  val read_stream: ?len: int -> t -> OS.Io_page.t Lwt_stream.t
  90
+  val read_line: t -> OS.Io_page.t list Lwt.t
  91
+
  92
+  val write_char : t -> char -> unit
  93
+  val write_string : t -> string -> int -> int -> unit
  94
+  val write_buffer : t -> OS.Io_page.t -> unit
  95
+  val write_line : t -> string -> unit
96 96
 
97 97
   val flush : t -> unit Lwt.t
98 98
   val close : t -> unit Lwt.t

0 notes on commit 3d886b5

Please sign in to comment.
Something went wrong with that request. Please try again.