http://qs1969.pair.com?node_id=61136


in reply to RE(4): MP3 server with IO::Socket
in thread MP3 server with IO::Socket

Hi folks, I've been experiencing the same problem that was reported earlier ("it seems to be going very fast"). I'm on Win32 (both NT4 and Win2k) and played around with the script for a while before figuring out a fix. It looks like a:
BINMODE(SONG);
fixes all. I also took out the forking-ness of the server, just to simplify the debug process, but I'm sure that's OK. With the fix in place, the code segment now looks like this:
<text cut> ... #what song are we playing warn( "play song: $song\n"); #open the song, or continue to try another one open (SONG, $song) || next; #### NEW CODE #### binmode (SONG); #### END NEW CODE #### my $read_status = 1; my $print_status = 1; my $chunk; .... <end cut>
I think this fix suggests that somewhere in the MP3's being streamed, read() was encountering what it thought was an EOF, where in fact it was misinterpreting the data. Am I right? (I guessed at binmode, read the cookbook, then understood)

Hope this helps,

Brainiac