From: Tim Bunce Date: Fri, 5 Sep 1997 00:00:00 +0000 (+0000) Subject: IO::Socket autoflush by default, assume tcp and PeerAddr X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e713eafe23a3705fd7c6cdfd19c5ba8c92d67fba;p=p5sagit%2Fp5-mst-13.2.git IO::Socket autoflush by default, assume tcp and PeerAddr (this is the same change as commit d103aadb464fdc9458aeaedf1165336dcbe99ff0, but as applied) --- diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm index ab19170..aadb502 100644 --- a/ext/IO/lib/IO/Socket.pm +++ b/ext/IO/lib/IO/Socket.pm @@ -39,6 +39,11 @@ C only looks for one key C which tells new which domain the socket will be in. All other arguments will be passed to the configuration method of the package for that domain, See below. +Cs will be in autoflush mode after creation. Note that +versions of IO::Socket prior to 1.1603 (as shipped with Perl 5.004_04) +did not do this. So if you need backward compatibility, you should +set autoflush explicitly. + =back =head1 METHODS @@ -118,7 +123,7 @@ use Exporter; @ISA = qw(IO::Handle); -$VERSION = "1.1602"; +$VERSION = "1.1603"; sub import { my $pkg = shift; @@ -129,6 +134,7 @@ sub import { sub new { my($class,%arg) = @_; my $fh = $class->SUPER::new(); + $fh->autoflush; ${*$fh}{'io_socket_timeout'} = delete $arg{Timeout}; @@ -392,7 +398,7 @@ and some related methods. The constructor can take the following options PeerPort Remote port or service [()] | LocalAddr Local host bind address hostname[:port] LocalPort Local host bind port [()] | - Proto Protocol name "tcp" | "udp" | ... + Proto Protocol name (or number) "tcp" | "udp" | ... Type Socket type SOCK_STREAM | SOCK_DGRAM | ... Listen Queue size for listen Reuse Set SO_REUSEADDR before binding @@ -410,10 +416,13 @@ parenthesis which is used if the service is not known by the system. The C specification can also be embedded in the C by preceding it with a ":". -Only one of C or C needs to be specified, one will be -assumed from the other. If you specify a symbolic C port, -then the constructor will try to derive C and C from -the service name. +If C is not given and you specify a symbolic C port, +then the constructor will try to derive C from the service +name. As a last resort C "tcp" is assumed. The C +parameter will be deduced from C if not specified. + +If the constructor is only passed a single argument, it is assumed to +be a C specification. Examples: @@ -428,6 +437,9 @@ Examples: LocalPort => 9000, Proto => 'tcp'); + $sock = IO::Socket::INET->new('127.0.0.1:25'); + + =head2 METHODS =over 4 @@ -463,6 +475,13 @@ peer host in a text form xx.xx.xx.xx =cut +sub new +{ + my $class = shift; + unshift(@_, "PeerAddr") if @_ == 1; + return $class->SUPER::new(@_); +} + sub _sock_info { my($addr,$port,$proto) = @_; my @proto = (); @@ -535,6 +554,7 @@ sub configure { unless(defined $raddr); } + $proto ||= (getprotobyname "tcp")[2]; return _error($fh,'Cannot determine protocol') unless($proto);