diff options
Diffstat (limited to 'portal/tcp/portal.ml')
-rw-r--r-- | portal/tcp/portal.ml | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/portal/tcp/portal.ml b/portal/tcp/portal.ml index d70d21b..72074a5 100644 --- a/portal/tcp/portal.ml +++ b/portal/tcp/portal.ml @@ -1,8 +1,7 @@ open Lwt.Syntax -open Lwt_unix open Markup -type socket = file_descr +type socket = Lwt_unix.file_descr type t = { mutable stream : (signal, async) stream; @@ -61,7 +60,8 @@ let close = [`End_element] |> Markup.of_list let xmpp_port (_domain : string) : int = 5222 (** [tcp_socket domain] is a plaintext TCP socket to the XMPP server [domain]. *) -let tcp_socket (domain : string) : file_descr Lwt.t = +let tcp_socket (domain : string) : Lwt_unix.file_descr Lwt.t = + let open Lwt_unix in let get_socket {ai_addr; ai_family; _} = let sock = socket ai_family SOCK_STREAM 0 in let+ () = Lwt_unix.connect sock ai_addr @@ -77,13 +77,13 @@ let socket_to_stream (sock : socket) = Lwt_stream.from (fun () -> let bsize = 4096 in let buffer = Bytes.create bsize in - let* len = read sock buffer 0 bsize + let* len = Lwt_unix.read sock buffer 0 bsize in match len with | 0 -> Lwt.return_none | len -> Lwt.return_some (Bytes.sub_string buffer 0 len)) and send_char c = (* This is gross, but it doesn't matter because TCP does buffering. *) - let+ _ = write_string sock (Char.escaped c) 0 1 in () + let+ _ = Lwt_unix.write_string sock (Char.escaped c) 0 1 in () and xml_stream, xml_push = Lwt_stream.create () in let push msg = let none () = xml_push None |