Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a function to open a connection to a server

  • Loading branch information...
commit ddfe622fa06cf77017cbe66397ccff83056b5595 1 parent 2aa7e79
John Else authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/irc_client.ml
10 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
Please sign in to comment.
Something went wrong with that request. Please try again.