in reply to From socket to socket

The short answer is yes.

Update:

If you want to fix up this code which I just knocked up, feel free. It's almost there. Just not all the way.
Maybe somebody else can find the problem. I have gotto fix some other stuff though.
Anyway, you should get the idea and hopefully you or somebody else can post a *completely working piece of code
so you can just go right ahead and use it*, or fix up the broken part of the following code.

Code Below blot:

If you output the data to file, then open it from your media player it works fine, it's just a small fault connection/handshake issue on the socket that doesn't allow the media player to take the binary data after it connects.

Go for your lives anybody. Like I said, I am busy with other projects that are more pressing.

Cheers.
use IO::Socket::INET; my $server; my $client; my $stream_sock_data = ""; pipe($reader, $writer); if($parent_pid = fork()) { # parent get_stream(); }else{ # child start_server(); } sub start_server { $server = IO::Socket::INET->new( LocalPort => 9999, Proto => 'tcp', Listen => '8' ) or die $!; while(my $client = $server->accept) { $resp = <$client>; if($resp =~ /GET/i) { print $client "HTTP\/1.0 OK 200\n\n"; $can_write = 1; while($can_write == 1) { $stream_sock_data = <$reader>; $can_write = print $client $stream_sock_data; } close($client); print "Client disconnected ...\n"; } } } sub get_stream { my $stream_sock = IO::Socket::INET->new( PeerPort => 8000, PeerAddr => "x.x.x.x", Proto => 'tcp' ) or die $!; print $stream_sock "GET /blahblahblah HTTP\/1.0\n\n"; $resp = <$stream_sock>; if($resp =~ /OK/i) { print "Connected to stream server ...Getting data ...\n"; while($stream_sock_data = <$stream_sock>) { print $writer $stream_sock_data; } } }

Replies are listed 'Best First'.
Re^2: From socket to socket
by wizbancp (Sexton) on Feb 16, 2007 at 08:07 UTC
    Great!
    thanks! i'm going to study your code =:^)
    I Hope to solve the problem

    <----------------->
    Feel the Dark Power of Regular Expressions...