- my $conn = $server_conn->new($server_conn->{rproc});
- $conn->{sock} = $sock;
- my $rproc = &{$server_conn->{rproc}} ($conn, $sock->peerhost(), $sock->peerport());
- if ($rproc) {
- $conn->{rproc} = $rproc;
- my $callback = sub {_rcv($conn)};
- set_event_handler ($sock, "read" => $callback);
- } else { # Login failed
- $conn->disconnect();
- }
+ if ($sock) {
+ my $conn = $server_conn->new($server_conn->{rproc});
+ $conn->{sock} = $sock;
+ blocking($sock, 0);
+ $conn->{blocking} = 0;
+ my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
+ $conn->{sort} = 'Incoming';
+ if ($eproc) {
+ $conn->{eproc} = $eproc;
+ set_event_handler ($sock, error => $eproc);
+ }
+ if ($rproc) {
+ $conn->{rproc} = $rproc;
+ my $callback = sub {$conn->_rcv};
+ set_event_handler ($sock, read => $callback);
+ } else { # Login failed
+ &{$conn->{eproc}}($conn, undef) if exists $conn->{eproc};
+ $conn->disconnect();
+ }
+ } else {
+ dbg("Msg: error on accept ($!)") if isdbg('err');
+ }