Skip to content

Commit

Permalink
Fixes for 4.06.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kayceesrk committed Apr 10, 2018
1 parent ab5a723 commit fb40489
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions sources/echo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Make (Aio : sig
(* Are the sockets non-blocking *)
end) = struct
let send sock str =
let len = String.length str in
let len = Bytes.length str in
let total = ref 0 in
(try
while !total < len do
Expand All @@ -52,7 +52,7 @@ end) = struct
try Aio.recv sock str 0 maxlen []
with _ -> 0
in
String.sub str 0 recvlen
Bytes.sub str 0 recvlen

let close sock =
try Unix.shutdown sock Unix.SHUTDOWN_ALL
Expand All @@ -68,8 +68,8 @@ end) = struct
let rec echo_server sock addr =
try
let data = recv sock 1024 in
if String.length data > 0 then
(ignore (send sock ("server says: " ^ data));
if Bytes.length data > 0 then
(ignore (send sock (Bytes.cat (Bytes.of_string ("server says: ")) data));
echo_server sock addr)
else
let cn = string_of_sockaddr addr in
Expand Down
2 changes: 1 addition & 1 deletion sources/echo_unix.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module M = Echo.Make(struct
let accept = Unix.accept
let accept fd = Unix.accept fd
let recv = Unix.recv
let send = Unix.send
let fork f = f ()
Expand Down

0 comments on commit fb40489

Please sign in to comment.