108 |
t.wfbuf.buf <- ""; |
t.wfbuf.buf <- ""; |
109 |
close t.sock (Printf.sprintf "%s after %d/%d" s t.nread t.nwrite) |
close t.sock (Printf.sprintf "%s after %d/%d" s t.nread t.nwrite) |
110 |
with e -> |
with e -> |
111 |
lprintf "Exception %s in TcpBufferedSocket.close" |
lprintf "Exception %s in TcpBufferedSocket.close\n" |
112 |
(Printexc2.to_string e); lprint_newline (); |
(Printexc2.to_string e); |
113 |
raise e |
raise e |
114 |
end |
end |
115 |
|
|
120 |
end; |
end; |
121 |
*) |
*) |
122 |
(try BasicSocket.shutdown t.sock s with e -> |
(try BasicSocket.shutdown t.sock s with e -> |
123 |
lprintf "exception %s in shutdown" (Printexc2.to_string e); |
lprintf "exception %s in shutdown\n" (Printexc2.to_string e)); |
|
lprint_newline () ); |
|
124 |
(try close t s with e -> |
(try close t s with e -> |
125 |
lprintf "exception %s in shutdown" (Printexc2.to_string e); |
lprintf "exception %s in shutdown\n" (Printexc2.to_string e)) |
|
lprint_newline ()) |
|
126 |
|
|
127 |
let buf_create max = |
let buf_create max = |
128 |
{ |
{ |
210 |
end |
end |
211 |
else |
else |
212 |
if b.len + len > b.max_buf_size then begin |
if b.len + len > b.max_buf_size then begin |
213 |
lprintf "BUFFER OVERFLOW %d+%d> %d" b.len len b.max_buf_size ; |
lprintf "BUFFER OVERFLOW %d+%d> %d\n" b.len len b.max_buf_size ; |
|
lprint_newline (); |
|
214 |
|
|
215 |
lprintf "MESSAGE ["; |
lprintf "MESSAGE ["; |
216 |
for i = pos1 to pos1 + (mini len 20) - 1 do |
for i = pos1 to pos1 + (mini len 20) - 1 do |
217 |
lprintf "(%d)" (int_of_char s.[i]); |
lprintf "(%d)" (int_of_char s.[i]); |
218 |
done; |
done; |
219 |
if len > 20 then lprintf "..."; |
if len > 20 then lprintf "..."; |
220 |
lprintf "]"; lprint_newline (); |
lprintf "]\n"; |
221 |
|
|
222 |
t.event_handler t BUFFER_OVERFLOW; |
t.event_handler t BUFFER_OVERFLOW; |
223 |
end |
end |
533 |
|
|
534 |
let create name fd handler = |
let create name fd handler = |
535 |
if !debug then begin |
if !debug then begin |
536 |
lprintf "[fd %d %s]" (Obj.magic fd) name; lprint_newline (); |
lprintf "[fd %d %s]\n" (Obj.magic fd) name; |
537 |
end; |
end; |
538 |
MlUnix.set_close_on_exec fd; |
MlUnix.set_close_on_exec fd; |
539 |
let t = { |
let t = { |
602 |
with |
with |
603 |
Unix.Unix_error((Unix.EINPROGRESS|Unix.EINTR),_,_) -> t |
Unix.Unix_error((Unix.EINPROGRESS|Unix.EINTR),_,_) -> t |
604 |
| e -> |
| e -> |
605 |
lprintf "For host %s port %d" (Unix.string_of_inet_addr host) |
lprintf "For host %s port %d\n" |
606 |
port; lprint_newline (); |
(Unix.string_of_inet_addr host) port; |
607 |
close t "connect failed"; |
close t "connect failed"; |
608 |
raise e |
raise e |
609 |
with e -> |
with e -> |
610 |
lprintf "+++ Exception BEFORE CONNECT %s" (Printexc2.to_string e); |
lprintf "+++ Exception BEFORE CONNECT %s\n" (Printexc2.to_string e); |
|
lprint_newline (); |
|
611 |
raise e |
raise e |
612 |
|
|
613 |
|
|