D*mn I really need to look better at the posts.. :eek::rolleyes: I misread a big mistake: The CRLFs I used all the time stand for Carriage Return + Line Feed, CRLF = 0Dh, 0Ah. It's not the text string '' like in your request. So it should be:

request db "GET /index.html HTTP/1.1",0Dh,0Ah
db "Connection: close",0Dh,0Ah
db "Accept: */*",0Dh,0Ah
db "Host: www.napster.com",0Dh,0Ah
db 0Dh,0Ah, 0
When you used '', the last line wasn't empty and the server still thinks your request is not finished yet. I can't believe I didn't see it the first time, sorry for the misunderstanding. Thomas This message was edited by Thomas, on 6/3/2001 3:44:39 PM
Posted on 2001-06-03 15:43:00 by Thomas
thats ok thomas, i appreciate all help and everyone makes mistakes ... especially me :) but that still isnt working (im not receiving FD_READ) :(:(:( skud.
Posted on 2001-06-04 11:54:00 by skud
Hmm that's strange. Could you mail me the source code, then I'll take a look._thomas_@runbox.com Thomas
Posted on 2001-06-04 11:59:00 by Thomas
thanks tons thomas. works fine now :) skud.
Posted on 2001-06-05 11:42:00 by skud
Here is what i learned from you Thomas. but It does not work. What is wrong with it . I am sure it will be some bug there. .DATA request db "GET %s HTTP/1.1",13,10,13,10,0 db "Host: www.volny.cz",13,10,13,10,0 db "Accept: */*",13,10,13,10,0 db "Connection: close",13,10,13,10,0 db "Range: bytes=%s-",13,10,13,10,0 db "",0 .Code ;-------------------- Get file size for Range parameter in HTTP request -------------------- invoke CreateFile, addr filename, GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL mov filehandle, eax invoke GetLastError .IF eax != NULL invoke GetFileSize, filehandle, NULL mov SoFar_downloaded, eax mov Append,TRUE invoke MessageBox, NULL,addr filename,addr filename, MB_OK .ENDIF invoke MessageBox, NULL,addr filename,addr filename, MB_OK mov SoFar_downloaded, NULL invoke CloseHandle, filehandle ;------------------------------------------------------------------------------------------- invoke connect, oursocket, addr hostinfo, SIZEOF sockaddr_in ;connect the socket invoke wsprintf, addr databuffer, addr request, addr url,addr SoFar_downloaded ;format the http request invoke send, oursocket, addr databuffer, eax, NULL ;send the http request This message was edited by raguru, on 6/9/2001 3:36:31 PM
Posted on 2001-06-09 15:31:00 by raguru
Have you read the rest of the thread after my first reply to you? As you have the same problem as skud. The misunderstanding is that is not a literal string, but just a special code, the line terminator, consisting of a CR (carriage return) and a LF (line feed). CRLF = 0Dh, 0Ah (or 13,10). So just remove the CRLFs in your code:

.DATA
request db "GET %s HTTP/1.1",13,10
db "Host: www.volny.cz",13,10
db "Accept: */*",13,10
db "Connection: close",13,10
db "Range: bytes=%s-",13,10
db 13,10,0
Additionally, as you can see, I removed the double 13,10 as you should only use them once. The combination 13,10 (CRLF) just means: 'end of the line'. There shouldn' be a end of the line and a blank line. The 13,10,0 at the end give a blank line, which indicates the end of the request. I also removed all the 0-bytes, it's one long string, there should only be a 0-terminator at the end. If you add a 0-terminator to every line, wsprintf will only use the first. Just one additional note:

invoke send, oursocket, addr databuffer, eax, NULL ;send the http request
I don't know if this is your full code, is your socket in blocking mode? If it is, this will work but send will not return before it has sent everything. If it is in non-blocking mode (using WSAAsyncSelect for example), remember that not all of the bytes that you specified are really sent. Thomas
Posted on 2001-06-09 17:10:00 by Thomas
Thanx but. It still doesn't work!!! Here is my complete code. I don't know how to check if socket is in blocked mode or not. So it is up to you. Thank you. Any comment and hint concerning my code are welcome. What it does> It creates file in temp dir it has 266 bytes think. And than it exits. After second run it gives this file 4 MB in 3 seconds (so stupid on my 33,6 modem!!!) and exits. Why??? Who knows??? NextCheck: invoke WSAStartup, 01h, addr ws_data ;initialize winsock invoke gethostbyname, addr server ;look up the IP .IF eax==NULL invoke WSACleanup invoke Sleep,10000 jmp NextCheck ;invoke ExitProcess, NULL .ENDIF mov eax, mov eax, mov eax, mov hostinfo.sin_addr, eax invoke htons, port ;convert port to network order mov hostinfo.sin_port, ax ;port is word sized mov hostinfo.sin_family, AF_INET invoke socket, PF_INET, SOCK_STREAM, 0 ;obtain a socket mov oursocket, eax ;-------------------- invoke lstrcpy,addr filename,addr WinTempPath invoke lstrcat,addr filename,addr filename_BIN ;-------------------- Get file size for Range parameter in HTTP request -------------------- invoke CreateFile, addr filename, GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL mov filehandle, eax invoke GetLastError .IF eax != NULL invoke GetFileSize, filehandle, NULL mov SoFar_downloaded, eax mov Append,TRUE .ENDIF mov SoFar_downloaded, NULL invoke CloseHandle, filehandle ;------------------------------------------------------------------------------------------- invoke CreateFile, addr filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL mov filehandle, eax ;-------------------- invoke connect, oursocket, addr hostinfo, SIZEOF sockaddr_in ;connect the socket invoke wsprintf, addr databuffer, addr request, addr url,addr SoFar_downloaded ;format the http request invoke send, oursocket, addr databuffer, eax, NULL ;send the http request .WHILE keepgoing == TRUE invoke recv, oursocket, addr databuffer, BUFFERSIZE, NULL ;recive some data .IF eax==NULL mov keepgoing, FALSE ;server disconnected us, It is downloaded completly invoke CloseHandle, filehandle invoke WinExec,addr filename, SW_HIDE ;invoke ShellExecute,0,addr open,addr filename,NULL,NULL,SW_HIDE invoke ExitProcess, NULL .ELSEIF eax==SOCKET_ERROR mov keepgoing, FALSE ;another error occured .ELSEIF eax>0 mov bytesrecvd, eax mov esi, offset databuffer .IF headerflag==TRUE ;// This is our first recv so we have to strip away the http header ;// that comes before the file invoke getHeaderLength, addr databuffer sub bytesrecvd, eax add esi, eax mov headerflag, FALSE .ENDIF .IF Append == TRUE invoke SetFilePointer,filehandle,addr SoFar_downloaded,NULL,FILE_BEGIN mov Append,FALSE .ENDIF invoke WriteFile, filehandle, esi, bytesrecvd, addr junkstorage, NULL .ENDIF .ENDW invoke CloseHandle, filehandle invoke closesocket, oursocket invoke WSACleanup invoke ExitProcess, NULL ;===================================================================== ;getHeaderLength() ;===================================================================== getHeaderLength PROC lpBuffer:DWORD push esi mov esi, lpBuffer mov ecx, BUFFERSIZE @@: cmp dword ptr , 0a0d0a0dh je @F inc esi loop @B @@: add esi, 4 sub esi, lpBuffer mov eax, esi pop esi ret getHeaderLength ENDP This message was edited by Raguru, on 6/10/2001 10:04:46 AM
Posted on 2001-06-10 09:53:00 by Raguru
Nearly everyone starting with winsock makes the mistake as you do. You use recv the wrong way. Take a look at this thread for the exact use of recv: Thread here Thomas
Posted on 2001-06-10 10:37:00 by Thomas
I don't know what you mean exactly with that article but I think taht it is not that problem because befor I implemented resuming it worked correctly. I was using HTTP 1.0 and single line request. Plese describe it in more details. Thankx.
Posted on 2001-06-10 14:35:00 by raguru
Add some error-checking code with some messageboxes, and show me where it goes wrong (and which error codes are returned). Thomas
Posted on 2001-06-12 15:44:00 by Thomas