From: Tony Toews [MVP] on
"mayayana" <mayaXXyana(a)rcXXn.com> wrote:


> With the userControl you'd just need to do
>a bit of editing. As it currently is I only have it set
>up for doing a GET.
>www.jsware.net/jsware/vbcode.php5#htp

Downloading a file or page that does exist works just fine. But what
is interesting is attempting to download a file from my website that
doesn't exist. I still see the -1 error code and the ErrStr is
unchanged at 10038. The text that is viewable "Get current File in
textbox" is the 404 raw HTML from IIS.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a free, convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
From: mayayana on

> But what
> is interesting is attempting to download a file from my website that
> doesn't exist. I still see the -1 error code and the ErrStr is
> unchanged at 10038. The text that is viewable "Get current File in
> textbox" is the 404 raw HTML from IIS.
>

10038 seems to be:
"Socket operation on nonsocket."

I don't really know what that means. It seems to
imply that the connection was broken off prematurely.
When I try to download a non-existing file I get a 404
as expected. I also just tried download "blah.html"
from these:

www.granite.ab.ca
msmvps.com
www.granitefleet.com

Each time I got a 404 as expected. I don't know what
might be different between our two systems or
connections, and I've never heard of anyone running
into that problem before.

I'm using the older winsock for compatibility (wsock32)
but I'd be surprised if that makes a difference. I think
that ws2_32.dll is a later version with the same functions,
and that there's a wsock2.dll on newer systems. I don't
know anything about wsock2.
If you decide to experiment with that you need to
change the first parameter in the call to WSAStartup.


From: Tony Toews [MVP] on
"mayayana" <mayaXXyana(a)rcXXn.com> wrote:

>> But what
>> is interesting is attempting to download a file from my website that
>> doesn't exist. I still see the -1 error code and the ErrStr is
>> unchanged at 10038. The text that is viewable "Get current File in
>> textbox" is the 404 raw HTML from IIS.
>>
>
>10038 seems to be:
>"Socket operation on nonsocket."

Interesting that. I'll poke about there then and see what might make
some sense. If anything.

> I don't really know what that means. It seems to
>imply that the connection was broken off prematurely.

And yet the 106 kb file I was expecting came down just fine.

>When I try to download a non-existing file I get a 404
>as expected. I also just tried download "blah.html"
>from these:
>
>www.granite.ab.ca
>msmvps.com
>www.granitefleet.com
>
>Each time I got a 404 as expected. I don't know what
>might be different between our two systems or
>connections, and I've never heard of anyone running
>into that problem before.

Bizarre. I'm running the exact download without making any changes.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a free, convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
From: Nobody on
"Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote in message
news:49ref5lk872bb5atk6n5ehli9rsarvbs26(a)4ax.com...
> I've been thinking about this and I feel I'd be much better off going
> directly against the Winsock rather than depending on IE stuff.
> Whatever MSs definition of stuff is. <smile>

I see that you are trying the Winsock approach, which is fine. However, you
would have to reinvent the wheel, or use a decent standard DLL if you need
to support proxy with authentication, if one of your users need it. When
there is such a proxy, you get status code 407(HTTP_STATUS_PROXY_AUTH_REQ),
and you have to resend the request again after authentication. The vbhttp
sample does handle this, so it saves you a lot of time. Search the source
code for HTTP_STATUS_PROXY_AUTH_REQ. See also this article:

How To Handle Proxy Authorization with WinInet
http://support.microsoft.com/kb/195650/EN-US/

The authentication is based on challenge/response method, which is not easy
to implement, but it's possible that someone made VB code to handle that if
you prefer the Winsock approach.

Also, the vbhttp sample doesn't save the file to disk, just display it. To
save it to disk, add the following line at the end of btGet_Click() event:

SaveFile App.Path & "\MyFile.bin", sBuffer


And add this routine to the form's code, or a standard module:

Private Sub SaveFile(ByRef fn As String, ByRef sContents As String)
Dim f As String

f = FreeFile
Open fn For Binary As f
Put f, , sContents
Close f
End Sub

But remember to check the status code, otherwise you get the textual
response that the user sees in the browser, such as "500 Internal Error", or
a fancy 404 error page instead of the actual file.



From: mayayana on
> > I don't really know what that means. It seems to
> >imply that the connection was broken off prematurely.
>
> And yet the 106 kb file I was expecting came down just fine.
>

? I mean that the error on the non-existing file
seems to indicate the connection was broken.
Am I misinderstanding? With a successful
communication (whether there's a file or not)
the return code (from the RequestFile function)
should be 0 while the server code should be 200,
301, 404, etc. I was assuming that you got 200
in the iErrCode box when you downloaded a file,
with return code of 0.
(You can't get anything but 0 or 99+ on the return,
code, which shows in the upper box marked
"return code".)

Then it sounded like when you tried to download
a non-existing file you got a return
code of 0 but got -1 for the iErrCode. That means that
something went wrong in a call to recv (which I've
renamed WReceive for clarity). So the server connection
was fine, and you got the header, but somehow it didn't
end cleanly.

Have I got that right? Another thought I had: It sounds
like you're doing GETs, but if you're doing HEAD that might
make a difference. The T1_MouseUp sub in the UC is where
the data gets received. It keeps receiving until it gets a
0 (no more data) or -1 (error from WReceive). What you see
in the program window is the return from OnDownloadFinish,
either the server code or -1, depending on the call to WReceive.
When you send HEAD you only need to get one return,
and I haven't coded for that. Maybe the server never sends
a Close signal in that case, or some such? I don't know
exactly how a HEAD conversation works. But the symptoms
seem to fit: A successful server interaction but with an
error when it finishes.




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