Harald,

| If the Abort routine intervenes and invalidates $data,
| the next read finds an invalid pointer or, worse, a pointer to an invalid
| buffer.
That's the key thing. How to stop the routine from reading data once and for 
all. Even
when I close the connection between the two handles it continues to read.

| If this theory is correct, then there is really no other way than to
| move the $data->abort() in the thread that reads from the socket, so that
| these two commands can never execute concurrently.
Maybe you are a bit confused. There are two abort routines. One fired by the 
button being
pressed and the other to close the socket. Here is the loop that reads and 
writes the data
from the socket.

# Open a socket for retrieval #
$data = $sock->retr($RemoteFile);
while(1) {
    Win32::GUI::DoEvents();
    last unless $len = $data->read($buffer,$blksize);
    my $written = syswrite(FILE, $buffer, $len);
    unless(defined($written) && $written == $len) {
        Msg_Box("Cannot write to local file $LocalFile: $!",48,"Can't Write To 
File");
        $data->abort;
        close(FILE);
        return undef;
    }
}

Then I have a window which displays the progress with an "Abort" button, which 
I already
gave the code.
I need to exit this loop once and for all, once the connection has been closed. 
The answer
is there...just gotta find it...someone...anyone.


regards,

erick
never stop questioning
www.jeb.ca


Reply via email to