Skip to content

Commit

Permalink
Add a function to open a connection to a server
Browse files Browse the repository at this point in the history
  • Loading branch information
johnelse committed Apr 2, 2013
1 parent 2aa7e79 commit ddfe622
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/irc_client.ml
Expand Up @@ -29,4 +29,14 @@ module Make(Io: Irc_transport.IO) = struct
let send_user ~connection ~username ~mode ~realname = let send_user ~connection ~username ~mode ~realname =
send_raw ~connection send_raw ~connection
~data:(Printf.sprintf "USER %s %i * :%s" username mode realname) ~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 end

0 comments on commit ddfe622

Please sign in to comment.