… | |
… | |
89 | Create a new non-blocking tcp handle and connect to the given host |
89 | Create a new non-blocking tcp handle and connect to the given host |
90 | and port. The parameter names and values are mostly the same as for |
90 | and port. The parameter names and values are mostly the same as for |
91 | IO::Socket::INET (as ugly as I think they are). |
91 | IO::Socket::INET (as ugly as I think they are). |
92 | |
92 | |
93 | The parameters officially supported currently are: C<ReuseAddr>, |
93 | The parameters officially supported currently are: C<ReuseAddr>, |
94 | C<LocalPort>, C<LocalHost>, C<PeerPort>, C<PeerHost>, C<Listen>, C<Timeout>. |
94 | C<LocalPort>, C<LocalHost>, C<PeerPort>, C<PeerHost>, C<Listen>, C<Timeout>, |
|
|
95 | C<SO_RCVBUF>, C<SO_SNDBUF>. |
95 | |
96 | |
96 | $fh = new Coro::Socket PeerHost => "localhost", PeerPort => 'finger'; |
97 | $fh = new Coro::Socket PeerHost => "localhost", PeerPort => 'finger'; |
97 | |
98 | |
98 | =cut |
99 | =cut |
99 | |
100 | |
… | |
… | |
141 | if ($arg->{Broadcast}) { |
142 | if ($arg->{Broadcast}) { |
142 | $self->setsockopt (SOL_SOCKET, SO_BROADCAST, 1) |
143 | $self->setsockopt (SOL_SOCKET, SO_BROADCAST, 1) |
143 | or croak "setsockopt(SO_BROADCAST): $!"; |
144 | or croak "setsockopt(SO_BROADCAST): $!"; |
144 | } |
145 | } |
145 | |
146 | |
|
|
147 | if ($arg->{SO_RCVBUF}) { |
|
|
148 | $self->setsockopt (SOL_SOCKET, SO_RCVBUF, $arg->{SO_RCVBUF}) |
|
|
149 | or croak "setsockopt(SO_RCVBUF): $!"; |
|
|
150 | } |
|
|
151 | |
|
|
152 | if ($arg->{SO_SNDBUF}) { |
|
|
153 | $self->setsockopt (SOL_SOCKET, SO_SNDBUF, $arg->{SO_SNDBUF}) |
|
|
154 | or croak "setsockopt(SO_SNDBUF): $!"; |
|
|
155 | } |
|
|
156 | |
146 | if ($arg->{LocalPort} || $arg->{LocalHost}) { |
157 | if ($arg->{LocalPort} || $arg->{LocalHost}) { |
147 | my @sa = _sa($arg->{LocalHost} || "0.0.0.0", $arg->{LocalPort} || 0, $arg->{Proto}); |
158 | my @sa = _sa($arg->{LocalHost} || "0.0.0.0", $arg->{LocalPort} || 0, $arg->{Proto}); |
148 | $self->bind ($sa[0]) |
159 | $self->bind ($sa[0]) |
149 | or croak "bind($arg->{LocalHost}:$arg->{LocalPort}): $!"; |
160 | or croak "bind($arg->{LocalHost}:$arg->{LocalPort}): $!"; |
150 | } |
161 | } |