From: mayayana on

> > I'm still unclear whether you've tried initializing
> >winsock, and what happens then. It should work
> >properly because the variable HSock will contain
> >a handle for that particular session and close the
> >connection appropriately.
>
> I've tried that in the past as well as today and no difference in
> behavior. I still get the repeated -1s.
>

Odd. It sounds like you're somehow using
an open socket either way. I guess that's OK
as long as you set the return codes accordingly,
but I wonder about the what and the why of
the open socket.

I guess you could set a variable to know when
the download is done:

Private Sub T1_MouseUp(....
If Alldone = True then Exit sub
' AllDone would be set to True with first 0 or -1

Then assuming you get a zero before a -1 you
can send back the server code and ignore future
data.

The way it normally works is that you first initialize
with WSAStartup. According to the docs:

"The WSAStartup function must be the first Windows Sockets function called
by an application or DLL."

Then the DisConnect call in the T1_MouseUp
sub calls WSAAsyncSelect, passing 0 for the
last two parameters and thereby cancelling
the callback. Somehow you're not getting the
callback cancelled.

You could check the return
on WSAAsyncSelect in the DisConnect sub. Oddly,
one possible error code is:

WSANOTINITIALISED A successful WSAStartup must occur before using this
function.

So that should have been returned on the first call
to set up the callback.

(See the MSDN docs on that function.)

You might also try substituting WS2_32.DLL for
wsock32 in the declares. That's the newer version
of winsock. I think wsock32 is only needed for
Win95 compatibility.


First  |  Prev  | 
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: Printing the Form
Next: Common Controls 5.0 / Windows 7