line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Socket::Class; |
2
|
|
|
|
|
|
|
# ============================================================================= |
3
|
|
|
|
|
|
|
# Socket::Class - A class to communicate with sockets |
4
|
|
|
|
|
|
|
# Use "perldoc Socket::Class" for documenation |
5
|
|
|
|
|
|
|
# ============================================================================= |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# enable for debugging |
8
|
|
|
|
|
|
|
#use strict; |
9
|
|
|
|
|
|
|
#use warnings; |
10
|
|
|
|
|
|
|
#no warnings 'uninitialized'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our( $VERSION ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN { |
15
|
1
|
|
|
1
|
|
700
|
$VERSION = '2.258'; |
16
|
1
|
|
|
|
|
8
|
require XSLoader; |
17
|
1
|
|
|
|
|
862
|
XSLoader::load( __PACKAGE__, $VERSION ); |
18
|
1
|
|
|
|
|
7
|
*say = \&writeline; |
19
|
1
|
|
|
|
|
3
|
*sleep = \&wait; |
20
|
1
|
|
|
|
|
3
|
*fileno = \&handle; |
21
|
1
|
|
|
|
|
275
|
*remote_name = \&get_hostname; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; # return |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub import { |
27
|
0
|
|
|
0
|
|
|
my $pkg = shift; |
28
|
0
|
|
|
|
|
|
my $callpkg = caller; |
29
|
0
|
0
|
|
|
|
|
@_ or return; |
30
|
0
|
0
|
|
|
|
|
$Socket::Class::Const::VERSION |
31
|
|
|
|
|
|
|
or require Socket::Class::Const; |
32
|
0
|
|
|
|
|
|
&Socket::Class::Const::export( $callpkg, @_ ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub printf { |
36
|
0
|
0
|
|
0
|
1
|
|
if( @_ < 2 ) { |
37
|
0
|
0
|
|
|
|
|
require Carp unless $Carp::VERSION; |
38
|
0
|
|
|
|
|
|
&Carp::croak( 'Usage: Socket::Class::printf(this,fmt,...)' ); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
my( $sock, $fmt ) = ( shift, shift ); |
41
|
0
|
|
|
|
|
|
return $sock->write( sprintf( $fmt, @_ ) ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub reconnect { |
45
|
0
|
0
|
0
|
0
|
1
|
|
if( @_ < 1 || @_ > 2 ) { |
46
|
0
|
0
|
|
|
|
|
require Carp unless $Carp::VERSION; |
47
|
0
|
|
|
|
|
|
&Carp::croak( 'Usage: Socket::Class::reconnect(this,wait=0)' ); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
my $this = shift; |
50
|
0
|
0
|
|
|
|
|
$this->close() or return undef; |
51
|
0
|
0
|
|
|
|
|
$this->wait( $_[0] ) if $_[0]; |
52
|
0
|
0
|
|
|
|
|
$this->connect() or return undef; |
53
|
0
|
|
|
|
|
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub include_path { |
57
|
0
|
|
|
0
|
0
|
|
return substr( __FILE__, 0, -16 ) . '/auto/Socket/Class'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |