… | |
… | |
101 | attempted, but after the file handle has been created. It could be used to |
101 | attempted, but after the file handle has been created. It could be used to |
102 | prepare the file handle with parameters required for the actual connect |
102 | prepare the file handle with parameters required for the actual connect |
103 | (as opposed to settings that can be changed when the connection is already |
103 | (as opposed to settings that can be changed when the connection is already |
104 | established). |
104 | established). |
105 | |
105 | |
|
|
106 | The return value of this callback should be the connect timeout value in |
|
|
107 | seconds (or C<0>, or C<undef>, or the empty list, to indicate the default |
|
|
108 | timeout is to be used). |
|
|
109 | |
106 | =item on_connect => $cb->($handle, $host, $port, $retry->()) |
110 | =item on_connect => $cb->($handle, $host, $port, $retry->()) |
107 | |
111 | |
108 | This callback is called when a connection has been successfully established. |
112 | This callback is called when a connection has been successfully established. |
109 | |
113 | |
110 | The actual numeric host and port (the socket peername) are passed as |
114 | The actual numeric host and port (the socket peername) are passed as |
… | |
… | |
444 | } else { |
448 | } else { |
445 | if ($self->{on_connect_error}) { |
449 | if ($self->{on_connect_error}) { |
446 | $self->{on_connect_error}($self, "$!"); |
450 | $self->{on_connect_error}($self, "$!"); |
447 | $self->destroy; |
451 | $self->destroy; |
448 | } else { |
452 | } else { |
449 | $self->fatal ($!, 1); |
453 | $self->_error ($!, 1); |
450 | } |
454 | } |
451 | } |
455 | } |
452 | }, |
456 | }, |
453 | sub { |
457 | sub { |
454 | local $self->{fh} = $_[0]; |
458 | local $self->{fh} = $_[0]; |
455 | |
459 | |
|
|
460 | $self->{on_prepare} |
456 | $self->{on_prepare}->($self) |
461 | ? $self->{on_prepare}->($self) |
457 | if $self->{on_prepare}; |
462 | : () |
458 | } |
463 | } |
459 | ); |
464 | ); |
460 | } |
465 | } |
461 | |
466 | |
462 | } else { |
467 | } else { |