ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Handle.pm
(Generate patch)

Comparing Coro/Coro/Handle.pm (file contents):
Revision 1.26 by root, Wed Jan 24 16:22:08 2007 UTC vs.
Revision 1.27 by root, Mon Mar 19 14:14:23 2007 UTC

113 my $obj = tied ${$_[0]}; 113 my $obj = tied ${$_[0]};
114 114
115 my $retval = $obj->[8]; 115 my $retval = $obj->[8];
116 $obj->[8] = $_[1] if @_ > 1; 116 $obj->[8] = $_[1] if @_ > 1;
117 $retval 117 $retval
118}
119
120=item connect, listen, bind, getsockopt, setsockopt,
121send, recv, peername, sockname, shutdown, peerport, peerhost
122
123Do the same thing as the perl builtins or IO::Socket methods (but return
124true on EINPROGRESS). Remember that these must be method calls.
125
126=cut
127
128sub connect { connect tied(${$_[0]})->[0], $_[1] or $! == Errno::EINPROGRESS }
129sub bind { bind tied(${$_[0]})->[0], $_[1] }
130sub listen { listen tied(${$_[0]})->[0], $_[1] }
131sub getsockopt { getsockopt tied(${$_[0]})->[0], $_[1], $_[2] }
132sub setsockopt { setsockopt tied(${$_[0]})->[0], $_[1], $_[2], $_[3] }
133sub send { send tied(${$_[0]})->[0], $_[1], $_[2], @_ > 2 ? $_[3] : () }
134sub recv { recv tied(${$_[0]})->[0], $_[1], $_[2], @_ > 2 ? $_[3] : () }
135sub sockname { getsockname tied(${$_[0]})->[0] }
136sub peername { getpeername tied(${$_[0]})->[0] }
137sub shutdown { shutdown tied(${$_[0]})->[0], $_[1] }
138
139=item ($fh, $peername) = $listen_fh->accept
140
141In scalar context, returns the newly accepted socket (or undef) and in
142list context return the ($fh, $peername) pair (or nothing).
143
144=cut
145
146sub accept {
147 my ($peername, $fh);
148 while () {
149 $peername = accept $fh, tied(${$_[0]})->[0]
150 and return wantarray
151 ? ($_[0]->new_from_fh($fh), $peername)
152 : $_[0]->new_from_fh($fh);
153
154 return unless $!{EAGAIN};
155
156 $_[0]->readable or return;
157 }
118} 158}
119 159
120=item $fh->timeout ([...]) 160=item $fh->timeout ([...])
121 161
122The optional argument sets the new timeout (in seconds) for this 162The optional argument sets the new timeout (in seconds) for this

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines