OCaml Forge
Bugs
Search the entire project
This project's trackers
This project's releases
This project's news
Project
People
Advanced search
Log In
New Account
Home
My Page
Projects
Code Snippets
Line Printer Deamon library
Summary
Activity
Tracker
News
SCM
Files
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
Product:
None
Operating System:
Linux
Component:
None
Version:
v1.0
Severity:
None
Resolution:
Won't Fix
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_to
none
2012-02-04 18:54
chris
Resolution
None
2012-02-04 18:54
chris