Dear All; I had a perl soft code, that allow client to connect to the MP3 server to play mp3 songs, however, I have tried this code under win2000, but it doesn't work at all. In my Laptop, it has a directory in drive d: "D:\Steve\Mp3" that contained the mp3 files, that I going to use for client to retrieve those mp3 songs, i have another laptop, that using peer-to-peer for the connection, but for the connection is fine, except mp3 server get error, and the client is rejected.
1- The mp3 server I run under cmd 2- I using Winnamp in client to retrieve the songs, the server display error as the following c:\mp3.pl # in server Acceptiong connection from 192.168.1.5 # in server Cannn't open: No such file or directory # in server 3- [error syncing to mpeg] http://192.168.1.4 # display when i try to retrieve the mp3 files in winnamp. Notice: 192.168.1.5 is the client that going to retireve those mp3 192.168.1.4 is the server Under Perl v5.8.4 (# ->commend) ================================================================================= #!/perl/bin/perl use strict; use IO::Socket::INET; use File::Find; my ( $sock, $connection ); $SIG{ INT } = sub { $connection->DESTROY if defined $connection; $sock->DESTROY if defined $sock; die "Caught interrupt\n" }; my $LIBRARY = "D:/Steve/mp3"; $sock = new IO::Socket::INET ( LocalHost => '192.168.1.4', LocalPort => 80, Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Can't create socket: $!\n " unless $sock; $sock->autoflush(1); my @songs; find( sub { push @songs, "$File::Find::dir/$_" if /\.mp3$/; }, $LIBRARY ); CONNECTION: while ( $connection = $sock->accept() ) { print "Accepting connection from ", $connection->peerhost(), " .\n"; print $connection "HTTP/1.0 200 OK\n"; print $connection "Content-Type: audio/x-mp3stream\n"; print $connection "Cache-Control: no-cache \n"; print $connection "Pragma: no-cache \n"; print $connection "Connection: close \n"; print $connection "x-audiocast-name: Crappy MP3 Server\n\n"; my $song = $songs[ rand @songs ]; local *SONG; open SONG, "<", $song or die "Cannn't open $song: $!\n"; print "\tPlaying $song\n"; binmode( SONG ); #for windows my ( $read_ok, $print_ok ) = ( 1, 1 ); while ( $read_ok and $print_ok ) { my $chunk; $read_ok = read ( SONG, $chunk, 1024 ); if ( defined $chunk and defined $read_ok ) { $print_ok = print $connection $chunk; } } close SONG; unless( defined $print_ok ) { $connection->close(); next CONNECTION; } } $sock->close(); exit( 0 ); =============================================================================================== -- May GOD blesses you, and your family _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs