recv is returning SOCKET_ERROR.
when i get the error using WSAGetLastError it returns
WSAECONNRESET (The virtual circuit was reset by the remote side. - ????)

as i am waiting to return 0 (no more data on the socket) to exit the loop of recv'ing and writing to the file it just keeps writing. when i close it using CTRL+ALT+DEL the file is HUGE. i look in it and its just the file i want repeated over and over.

How come if theres an error it can still download the file? even if it is HUGE!!

And what the hell is a virtual circuit? as its server side is there anything i can do about this? btw, this is HTTP.

thanks a lot.
Posted on 2001-09-06 14:49:14 by skud
ive had a read around, and this is what it says in my winsock help file:

If the socket is of type SOCK_STREAM and the remote side has shut down the connection gracefully, a recv() will complete immediately with 0 bytes received. If the connection has been abortively disconnected, a recv() will fail with the error WSAECONNRESET.

hmmm... according to this i have been abortively disconnected.
ok, so what can i do about it? as it seems to be server side i suppose i can try another server.

any ideas on how to tackle this problem more directly??

Posted on 2001-09-07 10:53:12 by skud
Most servers will immediately disconnect you if you 'don't speak proper HTTP'.. I.e. when you're sending weird binary data that can't be a valid http request, a server will disconnect you.. maybe there's a mistake in your request?

Posted on 2001-09-07 13:30:10 by Thomas
yeah that had crossed my mind.
the trouble is i "build" then request with wsprintf.
i have had trouble with getting the length of http requests in the past too (lstrlen). i will check it.

thanks a lot.
Posted on 2001-09-07 13:37:20 by skud
ok heres my code:




file db "File.txt",0

request db "GET /%s HTTP/1.1",0Dh,0Ah
db "Connection: close",0Dh,0Ah
db "Accept: */*",0Dh,0Ah
db "Host:",0Dh,0Ah
db 0Dh,0Ah
requestlen equ $-request



built_request db 256 dup (?)

request_length dd ?



invoke wsprintf,addr built_request,addr request,addr file

xor eax, eax
invoke lstrlen, addr file
add eax, requestlen
sub eax, 2
mov request_length, eax


i do need to sub the 2 for "%s" right? cos the "requestlen" is calculated at assembly time... so i hear :D

Posted on 2001-09-07 13:51:14 by skud
Well that's one way to do it, but why not use 'invoke StrLen, ADDR built_request'?
But the request seems okay so that shouldn't be a problem either..

Posted on 2001-09-07 14:25:04 by Thomas
because in my experience shit starts to happen when you use lstrlen on an http request. cos it reads everything except the terminating 0, and there isnt one in an http request :)

should it work ok though?

and what other reason could there be for it wanting to disconnect other than a bad http request?

Posted on 2001-09-07 14:35:31 by skud
"cos it reads everything except the terminating 0, and there isnt one in an http request "

Well then StrLen is exactly what you need! It returns the number of chars except the terminating 0, and that's exactly the length you need for send()...

Other disconnection causes? Ehmmm.... maybe something goes wrong with sending the data... I wouldn't know..
Are you using blocking-mode sockets? If yes, have a look at my attachment, it's a simple http request + response dump (but with HEAD instead of GET, thus returning only the headers)..
Posted on 2001-09-07 15:07:31 by Thomas
hmmmm, StrLen isnt in my win32.hlp
is it used the same as lstrlen?

i have done an http request before and it worked ok.
the only problem i had was new lines didnt come out properly. there was just a "|" where it should be. i heard that was to do with Linux servers or something... anyway i have a look at that source.

And I'm using blocking mode.

thanks a lot.
Posted on 2001-09-07 15:57:32 by skud
ive sorted it.
dammit. i had created the dialogboxparam wrong. hadnt specified the owned and didnt have any message handlers for it. oops. :) that happened cos it was originally a CreateThread.

thanks for all your help.
skud - 1st class muppet!
Posted on 2001-09-07 16:35:32 by skud
Oh well, at least you solved your problem :grin:

StrLen does the same as lstrlen, it is in the masm32lib that comes with the masm32package (includelib masm32.lib, include See \masm32\help\masmlib.hlp

Posted on 2001-09-07 17:33:13 by Thomas
just to answer the question about new lines in http requests.. it has to do with the *NIX standard for new line instead of CR/LF as in windows it's just CR (hmm or LF don't really remember right of the top of my head)... anyway this is waht makes it look wierd in windows... but if you look at it in a dos box it should look ok...
Posted on 2001-09-10 05:30:49 by NervGaz