line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XAS::Apps::Test::Echo::Client; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1175
|
use Try::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
6
|
1
|
|
|
1
|
|
348
|
use XAS::Lib::Net::Client; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XAS::Class |
9
|
1
|
|
|
|
|
3
|
version => $VERSION, |
10
|
|
|
|
|
|
|
base => 'XAS::Lib::App', |
11
|
|
|
|
|
|
|
accessors => 'handle port host send' |
12
|
1
|
|
|
1
|
|
5
|
; |
|
1
|
|
|
|
|
1
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# Public Methods |
16
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub setup { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$self->{handle} = XAS::Lib::Net::Client->new( |
22
|
|
|
|
|
|
|
-port => $self->port, |
23
|
|
|
|
|
|
|
-host => $self->host, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub do_echo { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $message; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->handle->connect(); |
34
|
0
|
|
|
|
|
|
$self->handle->puts($self->send); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$message = $self->handle->gets(); |
37
|
0
|
|
|
|
|
|
$self->handle->disconnect(); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->log->info(sprintf("echo = %s", $message)); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub main { |
44
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->setup(); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->log->debug('Starting main section'); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self->do_echo(); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$self->log->debug('Ending main section'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub options { |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->{send} = ''; |
60
|
0
|
|
|
|
|
|
$self->{port} = '9505'; |
61
|
0
|
|
|
|
|
|
$self->{host} = 'localhost'; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return { |
64
|
|
|
|
|
|
|
'port=s' => \$self->{port}, |
65
|
|
|
|
|
|
|
'host=s' => \$self->{host}, |
66
|
|
|
|
|
|
|
'send=s' => \$self->{send}, |
67
|
0
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
72
|
|
|
|
|
|
|
# Private Methods |
73
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
XAS::Apps::Test::Echo::Client - This module will send data to the echo server |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
use XAS::Apps::Test::Echo::Client; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $app = XAS::Apps::Test::Echo::Client->new(; |
88
|
|
|
|
|
|
|
-throws => 'echo-client', |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
exit $app->run(); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This module will send a message to the echo server. This message should be |
96
|
|
|
|
|
|
|
'echoed' back. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 CONFIGURATION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
There is no additional configuration. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 OPTIONS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This module provides these additonal cli options. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 --host |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The host the echo server resides on. Defaults to 'localhost'. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 --port |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The port it is listening on. Defaults to '9505'. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 --send |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The text to be "echoed" back. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over 4 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item bin/echo-client.pl |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item L<XAS|XAS> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright (C) 2012 by Kevin L. Esteb |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the terms of the Artistic License 2.0. For details, see the full text |
138
|
|
|
|
|
|
|
of the license at http://www.perlfoundation.org/artistic_license_2_0. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |