This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug in cygwin select/socket code(?)


The Perl code below creates a non-blocking socket and attempts
to connect it to 127.0.0.1:2 (which should be immediately refused),
The loop shows the socket becomes briefly writable according to
IO::Select. Is there some logic behind this that I'm missing?
It was ok in cygwin v1.3.12-2, but hasn't worked as I expected
in the last two releases (1.3.14-1, 1.3.15-2) .

Here's the output using v1.3.15:
$ perl -w testSockets.pl
sock created: Operation now in progress
Exception (Connection refused)
Writable (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
etc..


Here's the code I used:
use IO::Socket;
use IO::Select;
use strict;
use warnings;

my $sock = IO::Socket::INET->new(Proto=>'tcp') or warn $!;
$sock->blocking(0) or warn $!;
my $addr='127.0.0.1';
my $port=2;
$addr = inet_aton($addr) or warn("inet_aton: $!"), return undef;
my $sockaddr = sockaddr_in($port, $addr) or warn, return undef;
$sock->connect($sockaddr);
if ($sock) {print "sock created: $!\n"}
else {print "Immediate refusal: $!"; exit};
my $sel = IO::Select->new($sock) or warn;
while ($sel->handles) {
  if ($sel->has_exception(.001)) {
    print "Exception (", $!=$sock->sockopt(SO_ERROR), ")\n";
    };
  if ($sel->can_write(.001)) {
    print "Writable (", $!=$sock->sockopt(SO_ERROR), ")\n";
    };
  }

clerke




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]