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; } } }