in reply to Re^6: How do I display only matches
in thread (SOLVED) How do I display only matches
You may not know this (many folks don't), but no matter what the OS platform, when writing to a network socket, "\n" means <CR><LF>. ... So, yes, even on Unix, a write to network socket will be <CR><LF>, while a write to a disk file will be just <LF>.
The way you worded this actually annoyed me enough that I double-checked my knowledge on this.
serv.pl:
use warnings; use strict; use IO::Socket::INET; use Devel::Peek; my $sock = IO::Socket::INET->new(Listen => 5, LocalPort => 9000, LocalAddr => 'localhost', Proto => 'tcp') or die $!; my $cli = $sock->accept(); $cli->read(my $in, 5); Dump($in);
cli.pl:
use warnings; use strict; use IO::Socket::INET; my $sock = IO::Socket::INET->new("localhost:9000") or die $!; print $sock "foo\n\0\0";
Output of serv.pl:
SV = PV(0x573aeb89cfe0) at 0x573aeb8e2b50 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x573aeb8ed890 "foo\n\0"\0 CUR = 5 LEN = 10
And, a Wireshark capture of the raw packet on the wire shows:
66:6f:6f:0a:00:00
On Linux and on Windows. You're wrong on both of those counts as well. (You can add binmode $sock, ':crlf'; to the client, and it'll be 0d0a on both platforms, as expected.)
I hope this post adds more clarity to the issue.
No, it spreads false and confusing information.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: How do I display only matches
by jcb (Parson) on Sep 26, 2019 at 01:13 UTC | |
by haukex (Archbishop) on Sep 26, 2019 at 05:50 UTC | |
|
Re^8: How do I display only matches
by Marshall (Canon) on Sep 26, 2019 at 04:05 UTC | |
by haukex (Archbishop) on Sep 26, 2019 at 05:47 UTC | |
by Marshall (Canon) on Sep 28, 2019 at 04:28 UTC | |
by haukex (Archbishop) on Sep 28, 2019 at 07:22 UTC | |
by jcb (Parson) on Sep 26, 2019 at 22:46 UTC | |
by Marshall (Canon) on Sep 27, 2019 at 23:04 UTC | |
by jcb (Parson) on Sep 28, 2019 at 04:32 UTC | |
by haukex (Archbishop) on Sep 28, 2019 at 08:10 UTC | |
|