OCaml Forge
SCM

Detail: [#269] Socket.select is waiting too much.

Bugs: Browse | Download .csv | Monitor

[#269] Socket.select is waiting too much.

Date:
2009-08-15 15:56
Priority:
3
State:
Open
Submitted by:
Guillaume Yziquel (yziquel)
Assigned to:
Christophe Troestler (chris)
Hardware:
HP
Resolution:
Won't Fix
Severity:
None
Version:
v1.0
Component:
None
Operating System:
Linux
Product:
None
 
URL:
Summary:
Socket.select is waiting too much.

Detailed description
With the following code:

module Aux = struct

let string_of_char_list l =
String.concat "" (List.map (String.make 1) l)

end

let read_on_channel channel =
let trying = ref true in
let answer = ref [(let c = Socket.input_char channel in print_char c; flush stdout; c)] in
while !trying do
match begin match Socket.select [channel] [] 1. with
| (x::[]), [] when x = channel -> Some (let c = Socket.input_char channel in print_char c; flush stdout; c)
| [], [] -> None | _ -> (assert false); None end
with | None -> trying := false
| Some c -> answer := c::!answer
done;
Aux.string_of_char_list (List.rev !answer)

I get the following output:
# read_on_channel inch;;
<?xml version="1.0" encoding="UTF-8"?>

But the thing is, each character gets written after one second. It seems that select is waiting as long as 1. second, and not notifiying the program as soon as possible.

Followup

Message
Date: 2012-02-04 18:54
Sender: Christophe Troestler

The underlying implementation uses Unix.select. If this behavior still happens with the current version of OCaml, you should report a bug directly to the OCaml core devel. team.

Attached Files:

Changes:

Field Old Value Date By
assigned_tonone2012-02-04 18:54chris
ResolutionNone2012-02-04 18:54chris