1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/perl -w
use IO::Socket::INET;
use IO::Socket::Timeout;
use Errno qw(ETIMEDOUT EWOULDBLOCK);
# flush after every write
$| = 1;
my $socket;
$socket = new IO::Socket::INET (
PeerHost => '192.168.0.50',
PeerPort => '3629',
Proto => 'tcp',
Timeout => 2,
);
print "TCP Connection Success...";
print "Try to send....";
print $socket 0x45, 0x53, 0x43, 0x2f, 0x56, 0x50, 0x2e, 0x6e, 0x65, 0x74, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x50, 0x57, 0x52, 0x3f, 0x0D;
print "sended!\n";
print "Try to read....";
print "Received from Server : ";
print <$socket>;
$socket->close();
print "Socket closed.\n";
print "End.\n";
1 2 3
print "Try to send...."; my $data = pack("C*", 0x45, 0x53, 0x43, 0x2f, 0x56, 0x50, 0x2e, 0x6e, 0x65, 0x74, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x50, 0x57, 0x52, 0x3f, 0x0d); print $socket $data;
QuoteAs of VERSION 1.18 all IO::Socket objects have autoflush turned on by default.
QuoteIch habe die Perl-Ausgabe auch mal an einen PC umgeleitet (IP geändert) auf dem Hercules auf dem Port gelauscht hat. Die dort ankommenden Zeichen sind zugegeben etwas schwierig zu lesen, wenn ich das aber richtig sehe genau dass, was ich senden will
(Dez) 6983674786804611010111616300008087826313
my $s = IO::Socket::INET->new(...) or die $@;
$s->print(...) or die $^E;
Guest OliverCode: (dl )1
2print "Try to send....";
print $socket 0x45, 0x53, 0x43, 0x2f, 0x56, 0x50, 0x2e, 0x6e, 0x65, 0x74, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x50, 0x57, 0x52, 0x3f, 0x0D;
my $bin = pack "C*", 0x01, 0xAF, 0xEF ...
use IO::Socket;