Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RE(4): MP3 server with IO::Socket

by perlmonkey (Hermit)
on May 22, 2000 at 10:00 UTC ( #14159=note: print w/ replies, xml ) Need Help??


in reply to RE: RE: RE: MP3 server with IO::Socket
in thread MP3 server with IO::Socket

Well if you telnet to the port and it is printing the binary to the screen, then the server works. That is all it does. The whole purpose is to print binary to the socket. I would bet that the problem lies in your mp3 player, what player are you using and what OS are you using. I have been using this server in some form or another for about a year now, so I nearly positive that the problems you are having are not related to the server code (unless they are OS specific, in which case I probably cant help). But if you can track down the problems and the cause does lay in my code, then let me know and I will make the corrections.


Comment on RE(4): MP3 server with IO::Socket
Re: RE(4): MP3 server with IO::Socket
by brainiac (Initiate) on Feb 27, 2001 at 23:16 UTC
    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
      Thanks for the debugging!
      I dont use windows, so I never think about binmode.
      That routine doesnt hurt on unix, so I will add it into
      the server code for all to use.
      -perlmonkey
        Remember how I said I assumed the forking code was fine? Well, I grabbed your latest code posting, and to my surprise, it wouldn't run! After some more debugging (looks like I'm reading more code than I'm writing lately) I think I've found a contention issue (not really sure)...anywho:
        else { #i'm the parent! warn "(Parent) I'm the parent\n"; #who connected? warn "(Parent) Connecton recieved ... ",$connection>peerhost,"\n"; #close the connection, the parent has already passed # it off to a child. warn "(Parent) Closing connection\n"; sleep 3; $connection->close(); }
        Those extra warn statements lead me to believe that the parent was closing the $connection before the child got to call play_songs hence the sleep call. I chose "3" randomly, but it works fine now, and the sleep doesn't affect any of the logic or flow. Brainiac

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://14159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2014-09-01 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls