diff options
author | Lincoln Stein <lstein@formaggio.cshl.org> | 1999-07-28 09:55:05 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-07-28 18:13:37 +0000 |
commit | 8fd73a68c4e3e61c175bff5ea8257b8c0787333e (patch) | |
tree | c7f64699e6f8feb3fed0effdd83f534e56f79faa /ext/IO | |
parent | 8b0db79d1be7acb4277f629a0a1e576181b0ec8f (diff) | |
download | perl-8fd73a68c4e3e61c175bff5ea8257b8c0787333e.tar.gz |
IO::* enhancements.
1) write() and syswrite() will now accept a single-argument
form of the call, for consistency with Perl's syswrite().
2) You can create a TCP-based IO::Socket::INET without forcing
a connect attempt. This allows you to configure its options
(like making it non-blocking) and then call connect() manually.
3) Fixed a bug that prevented the IO::Socket::protocol() accessor
from ever returning the correct value.
To: Graham Barr <gbarr@pobox.com>
Cc: Lincoln Stein <lstein@cshl.org>, perl5-porters@perl.org
Subject: Re: patch for IO::*
Message-ID: <14239.17401.330408.145295@formaggio.cshl.org>
p4raw-id: //depot/cfgperl@3820
Diffstat (limited to 'ext/IO')
-rw-r--r-- | ext/IO/lib/IO/Handle.pm | 6 | ||||
-rw-r--r-- | ext/IO/lib/IO/Socket.pm | 2 | ||||
-rw-r--r-- | ext/IO/lib/IO/Socket/INET.pm | 3 |
3 files changed, 8 insertions, 3 deletions
diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm index 9b5dd6570e..2205368e96 100644 --- a/ext/IO/lib/IO/Handle.pm +++ b/ext/IO/lib/IO/Handle.pm @@ -417,13 +417,15 @@ sub sysread { } sub write { - @_ == 3 || @_ == 4 or croak 'usage: $io->write(BUF, LEN [, OFFSET])'; + @_ >= 2 && @_ <= 4 or croak 'usage: $io->write(BUF [, LEN [, OFFSET]])'; local($\) = ""; + $_[2] = length($_[1]) unless defined $_[2]; print { $_[0] } substr($_[1], $_[3] || 0, $_[2]); } sub syswrite { - @_ == 3 || @_ == 4 or croak 'usage: $io->syswrite(BUF, LEN [, OFFSET])'; + @_ >= 2 && @_ <= 4 or croak 'usage: $io->syswrite(BUF [, LEN [, OFFSET]])'; + $_[2] = length($_[1]) unless defined $_[2]; syswrite($_[0], $_[1], $_[2], $_[3] || 0); } diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm index 46205a6631..5cf9e72919 100644 --- a/ext/IO/lib/IO/Socket.pm +++ b/ext/IO/lib/IO/Socket.pm @@ -279,7 +279,7 @@ sub socktype { sub protocol { @_ == 1 or croak 'usage: $sock->protocol()'; my($sock) = @_; - ${*$sock}{'io_socket_protocol'}; + ${*$sock}{'io_socket_proto'}; } 1; diff --git a/ext/IO/lib/IO/Socket/INET.pm b/ext/IO/lib/IO/Socket/INET.pm index 367959565d..d7ca4c155d 100644 --- a/ext/IO/lib/IO/Socket/INET.pm +++ b/ext/IO/lib/IO/Socket/INET.pm @@ -149,6 +149,9 @@ sub configure { $raddr = shift @raddr; + # don't connect unless we're given a port or address + last unless defined($rport) || defined($raddr); + return _error($sock,'Cannot determine remote port') unless($rport || $type == SOCK_DGRAM || $type == SOCK_RAW); |