I Need to send files using HTTP protocols, but the question is should I use sockets because I have big files ? or I can use WinHttpApi such as :
BOOL HttpSendRequest(
__in HINTERNET hRequest,
__in LPCTSTR lpszHeaders,
__in DWORD dwHeadersLength,
__in LPVOID lpOptional,
__in DWORD dwOptionalLength
);
and use the lpOptional for the file I want ? and should I devide the file or this API handles big files?
Is there any limitation in files size if I used the HTTP apis and should I devide data?
HTTP uses TCP sockets for its connection:
(It could in principle use something else, but that would be quite unusual.)
The advantage of using an HTTP over designing your own protocol over a socket is that there are plenty of existing HTTP libraries (amongst other arguments). You would have to define your own little protocol anyway, if only to tell the remote party when the file starts and stops.
A few points that HTTP helps with:
Content-Lengthheader or chunked transfer encoding. This is necessary because you can’t generally distinguish clean and abrupt connection closures in TCP (API with a function likeisConnectedaren’t enough).If you do choose to use HTTP, try to read a bit more about it though. You may actually find that web servers and web clients already implement what you need. I’m not sure what
lpOptionalis about, but you should specify the file you want to get in the URL you construct. (Build your own URL space on your server.)