type handle = Unix.file_descr
+let handle_compare = compare
+
type conn_status =
| Connecting
| Listening
and conn_state =
{
- callbacks : conn_callbacks;
+ mutable callbacks : conn_callbacks;
mutable status : conn_status;
mutable send_done_enabled : bool;
mutable recv_enabled : bool;
let conn_state = ConnMap.find handle t.conns in
Buffer.length conn_state.send_buf > 0
+let set_callbacks t handle callbacks =
+ let conn_state = ConnMap.find handle t.conns in
+ conn_state.callbacks <- callbacks
+
(* timers *)
type timer = Timers.handle
| Connected ->
do_send t fd cs;
if Buffer.length cs.send_buf = 0 then begin
+ Unixext.Fdset.clear t.writers fd;
if cs.send_done_enabled then
- cs.callbacks.send_done_callback t fd;
- Unixext.Fdset.clear t.writers fd
+ cs.callbacks.send_done_callback t fd
end
let dispatch_timers t current_time =
error_callback : t -> handle -> error -> unit;
}
+(* this is to allow collections indexed by connection handles. *)
+val handle_compare : handle -> handle -> int
+
(* by default, connections are disabled for the send_done callback, and enabled for all others. *)
val register_conn : t -> Unix.file_descr -> ?enable_send_done:bool -> ?enable_recv:bool -> conn_callbacks -> handle
val remove_conn : t -> handle -> unit
val send : t -> handle -> string -> unit
val has_pending_send : t -> handle -> bool
+val set_callbacks : t -> handle -> conn_callbacks -> unit
+
(* timers *)
type timer