… | |
… | |
99 | $sock->blocking(0); |
99 | $sock->blocking(0); |
100 | |
100 | |
101 | my $input; $input = add_watch Glib::IO fileno $sock, [G_IO_IN, G_IO_ERR, G_IO_HUP], sub { |
101 | my $input; $input = add_watch Glib::IO fileno $sock, [G_IO_IN, G_IO_ERR, G_IO_HUP], sub { |
102 | # this is dorked |
102 | # this is dorked |
103 | my $buf; |
103 | my $buf; |
104 | if (0 >= sysread $sock, $buf, 16384 |
104 | my $len = sysread $sock, $buf, 16384; |
105 | and !$!{EINTR} and !$!{EAGAIN}) { |
105 | if ($len) { |
|
|
106 | $self->{conn}->feed_data($buf); |
|
|
107 | } elsif (defined $len || (!$!{EINTR} and !$!{EAGAIN})) { |
|
|
108 | warn "disconnected";#d# |
106 | remove Glib::Source $input; |
109 | remove Glib::Source $input; |
107 | $self->event_disconnect; |
110 | $self->event_disconnect; |
108 | } |
111 | } |
109 | $self->{conn}->feed_data($buf); |
|
|
110 | 1; |
112 | 1; |
111 | }, G_PRIORITY_HIGH; |
113 | }, G_PRIORITY_HIGH; |
112 | |
114 | |
113 | # now login |
115 | # now login |
114 | $self->{conn}->login($ENV{KGSUEME_CLIENTVER} || "kgsueme $VERSION $^O", # allow users to overwrite |
116 | $self->{conn}->login($ENV{KGSUEME_CLIENTVER} || "kgsueme $VERSION $^O", # allow users to overwrite |