enable proxy authentication for http client too
[mldonkey.git] / src / utils / net / tcpBufferedSocket.mli
blobb70bfcc3a2b93f78099f33bdbe572b82902e1f8a
1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
2 (*
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 type event =
20 WRITE_DONE
21 | CAN_REFILL
22 | CONNECTED
23 | BUFFER_OVERFLOW
24 | READ_DONE of int
25 | BASIC_EVENT of BasicSocket.event
28 and buf = {
29 mutable buf : string;
30 mutable pos : int;
31 mutable len : int;
32 mutable max_buf_size : int;
33 mutable min_buf_size : int;
36 type token
37 type t
39 type bandwidth_controler (* = {
40 mutable remaining_bytes : int;
41 mutable total_bytes : int;
42 mutable nconnections : int;
43 mutable connections : t list;
44 allow_io : bool ref;
45 mutable last_remaining : int;
46 mutable moved_bytes : int64;
51 and handler = t -> event -> unit
53 val max_buffer_size : int ref
55 val create : token -> string -> Unix.file_descr -> handler -> t
56 val create_simple : token -> string -> Unix.file_descr -> t
57 val create_blocking : token -> string -> Unix.file_descr -> handler -> t
58 val buf : t -> buf
59 val setsock_iptos_throughput : t -> unit
60 val set_reader : t -> (t -> int -> unit) -> unit
61 val sock_used : t -> int -> unit
62 val buf_create : int -> buf
63 val buf_used : buf -> int -> unit
64 val buf_add : t -> buf -> string -> int -> int -> unit
65 val set_handler : t -> event -> (t -> unit) -> unit
66 val set_refill : t -> (t -> unit) -> unit
67 val set_rtimer : t -> (t -> unit) -> unit
68 val write: t -> string -> int -> int -> unit
69 val write_string: t -> string -> unit
70 val connect: token -> string -> Unix.inet_addr -> int -> handler -> t
71 val close : t -> BasicSocket.close_reason -> unit
72 val closed : t -> bool
73 val shutdown : t -> BasicSocket.close_reason -> unit
74 val error: t -> BasicSocket.close_reason
75 (* val tcp_handler: t -> BasicSocket.t -> BasicSocket.event -> unit *)
76 val set_closer : t -> (t -> BasicSocket.close_reason -> unit) -> unit
77 val nread : t -> int
78 val set_max_input_buffer : t -> int -> unit
79 val set_max_output_buffer : t -> int -> unit
80 val can_write : t -> bool
81 val can_write_len : t -> int -> bool
82 val register_download : t -> int -> unit
83 val register_upload : t -> int -> unit
84 val register_bytes : bandwidth_controler option -> int -> unit
86 val set_monitored : t -> bool -> unit
87 val monitored : t -> bool
89 val close_after_write : t -> unit
91 val create_read_bandwidth_controler : string -> int -> bandwidth_controler
92 val create_write_bandwidth_controler : string -> int -> bandwidth_controler
93 val set_read_controler : t -> bandwidth_controler -> unit
94 val set_write_controler : t -> bandwidth_controler -> unit
95 val change_rate : bandwidth_controler -> int -> unit
98 val my_ip : t -> Ip.t
99 val peer_addr : t -> Ip.t * int
100 val peer_ip : t -> Ip.t
101 val peer_port : t -> int
102 (*val host : t -> Ip.t * int *)
104 val stats : Buffer.t -> t -> unit
105 val buf_size : t -> int * int
107 (* val if_possible : bandwidth_controler -> int -> bool *)
109 val set_rtimeout : t -> float -> unit
110 val set_wtimeout : t -> float -> unit
112 val internal_buf : Buffer.t
113 val value_send : t -> 'a -> unit
114 val value_handler : ('a -> t -> unit) -> t -> int -> unit
116 val set_write_power : t -> int -> unit
117 val set_read_power : t -> int -> unit
119 val remaining_to_write : t -> int
121 val set_lifetime : t -> float -> unit
123 val tcp_uploaded_bytes : int64 ref
124 val tcp_downloaded_bytes : int64 ref
125 val moved_bytes : bandwidth_controler -> int64
127 val set_remaining_bytes_user : bandwidth_controler ->
128 (int -> int -> unit) -> unit
129 val set_lost_bytes : bandwidth_controler -> int -> int -> unit
130 val compute_lost_byte : bandwidth_controler -> int
133 val exec_command : token -> string -> string array -> handler -> t * int
135 val not_buffer_more : t -> int -> bool
137 val nread : t -> int
138 val nwritten : t -> int
140 val accept_connection_bandwidth : t -> unit
142 val bind_address : Unix.inet_addr ref
143 val ip_packet_size : int ref
144 val mtu_packet_size : int ref
145 val minimal_packet_size : int ref
147 val get_rtimeout : t -> float * float
149 val http_proxy : (string * int * (string * string) option) option ref (* (host, port, (login, password)) *)
150 val copy_read_buffer : bool ref
152 type connection_manager
154 val unlimited_connection_manager : connection_manager
156 val create_connection_manager : string -> connection_manager
157 val add_pending_connection :
158 connection_manager -> (token -> unit) -> token
159 val can_open_connection : connection_manager -> bool
161 val reset_connection_scheduler : unit -> unit
163 val cancel_token : token -> unit
164 val create_token : connection_manager -> token
166 val set_max_opened_connections : (unit -> int) -> unit
167 val set_max_connections_per_second : (unit -> int) -> unit
169 val deflate_connection : t -> unit
170 val set_connected : t -> (t -> unit) -> unit
172 val prevent_close : t -> unit
173 val must_write : t -> bool -> unit
174 val max_refill : t -> int
175 val output_buffered : t -> int
177 val get_latencies : bool ref -> string
179 val string_of_event : event -> string