I'm writing a client application that connects to a server program
called via ssh, similar to the way git uses ssh as a transport
mechanism. Communication with the server program therefore occurs via
two separate file handles, one for reading and one for writing.
AnyEvent::Handle is both read and write aware for duplex filehandles
(sockets), but requires the use of two separate instances for the
ssh-transport case. In my case (presumably a common one?) the read
callbacks need to call write handle methods, and vice-versa, and
keeping track of objects and reference loops is complex.
It occurs to me looking at the source for AnyEvent::Handle that it
could be relatively easily modified to accept two extra constuctor
arguments, rfh and wfh, defaulting to the existing fh attribute:
# Standard interface, internally set wfh and rfh:
my $h = AnyEvent::Handle->new(
fh => \*DUPLEX,
);
# Or, create with two filehandles:
my $h = AnyEvent::Handle->new(
rfh => \*STDIN,
wfh => \*STDOUT,
);
# Use $h like a socket regardless
Internal calls to syswrite and sysread would be modified to use the
appropriate attribute.
Does this sound like something worth pursuing?
Mark.
--
Mark Lawrence
_______________________________________________
anyevent mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/anyevent