Update: I've isolated the problem to when the stream gets written to $buf1. I wrote <$lstream1> out and it had just x0As. After $buf1 = <$lstream1> then there were the incorrect x0D x0As. Any recommendations on using this buffer??
I have written a proxy that forwards data it receives to connected clients. It is written in ActivePerl running on a Windows system. When it receives a line feed (0A) character it writes out a carriage return (0D) and a line feed (0A). I need the input unmodified (ie just OA). How do I suppress the OD? I thought using binmode ($fh, ":raw") was supposed to help with this. Any thoughts?
Here is the portion that handles receiving the stream and sending to all connected clients...
sub stream1 {
my ($lstream1) = @_; #socket data comes in on
my $buf1; #buffer receiving stream
if($lstream1->connected) {
while(defined($buf1=<$lstream1>)) { #PROBLEM
foreach my $fn (@stream1_clients) { #all connected clients
open my $fh, ">&=$fn" or warn $! and die; #open socket to cli
+ent
binmode($fh, ":raw"); #thought this solved win/unix problems
print $fh $buf1;
}
$|++
}
}
my $stream_ip = $lstream1->peerhost;
print "* Stream 1 [$stream_ip:$stream1_prt] disconnected\n";
close($lstream1);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.