Permalink
Browse files

Add a function to open a connection to a server

  • Loading branch information...
1 parent 2aa7e79 commit ddfe622fa06cf77017cbe66397ccff83056b5595 @johnelse committed Apr 2, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/irc_client.ml
View
@@ -29,4 +29,14 @@ module Make(Io: Irc_transport.IO) = struct
let send_user ~connection ~username ~mode ~realname =
send_raw ~connection
~data:(Printf.sprintf "USER %s %i * :%s" username mode realname)
+
+ open Io
+
+ let connect ~server ~port ~username ~mode ~realname ~nick ~password =
+ Io.open_socket server port >>= (fun sock ->
+ let connection = {sock = sock} in
+ send_pass ~connection ~password
+ >>= (fun () -> send_nick ~connection ~nick)
+ >>= (fun () -> send_user ~connection ~username ~mode ~realname)
+ >>= (fun () -> return connection))
end

0 comments on commit ddfe622

Please sign in to comment.