From: Robert Klemme Date: 2007-11-03T00:35:55+09:00 Subject: Re: IOS troubles with binary data on windows 2007/11/2, Brandon Casci : > The chunk size isn't the problem. > > This code streams mp3 data to standard input for a pipe opened up an an > executable called ezstream. Ezstream is a source for icecast server. > > > here is @ezstream: > > @ezstream = IO.popen("C:\\Program > Files\\ezstream-0.4.3-win32\\ezstream.exe -c \"C:\\Program > Files\\ezstream-0.4.3-win32\\examples\\stdin.xml\"", "r+b") > > This code works on Windows: > > url = get_track_url > > Net::HTTP.start(url.host, url.port) do |http| > http.request_get(url.request_uri, {"User-Agent"=>"Mozilla/5.0 > (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 > Firefox/2.0"}) do |res| > raise "Bad response :#{res.code}: #{res.body}" unless res.code == > "200" > res.read_body do |segment| > @ezstream.write segment > end > end > end > > > This code does not work on Windows: > > f = File.open(get_file_path,'rb') > count = nil > until count == 0 > count = @ezstream.write(f.read(1024)) > #Invalid argument (Errno::EINVAL) > # you get a broken pipe exception with sysread and syswrite too > end > > Any ideas what is so different about chunking a file from disk versus > chunking the file from an http network stream? Check the documentation, especially the return value of #write. Note also the copying algorithm I suggested. Hint: your file copying is flawed. Cheers robert -- use.inject do |as, often| as.you_can - without end