Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Checking server for a file

This topic is 6853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

strange how i was just learning how to do the same thing =)

anyway, you can use the WinInet functions, which are pretty simple to use. first you have to create an internet handle, which is used to create everything else. after that, you connect to a specific site and file, then you can read the file. here's code:

code:
HINTERNET hInet = InternetOpen("name of this program", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET hConnect = InternetOpenUrl(hInet, "http://www.gamedev.net/blabla.bla", NULL, 0, 0, 0);

// read the file and write it somewhere
int fSave = _open("data.sav", _O_BINARY | _O_WRONLY | _O_CREAT, _S_IWRITE);

BYTE buff[1024];
DWORD dwRead;
while (InternetReadFile(hConnect, buff, 1024, &dwRead))
{
if (dwRead == 0)
break;
_write(fSave, buff, dwRead);
}
_close(fSave);
InternetCloseHandle(hConnect);
InternetCloseHandle(hInet);


hope that helps =) it also works with ftp. oh, and that string with "name of this program" can really be anything, i think it gets passed onto the server and can be used to profile the visitors, not sure on that however. you also have to include "wininet.h" and link to "wininet.lib"

------------------
http://members.xoom.com/mutex0

[This message has been edited by mutex (edited October 17, 1999).]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Does anyone know how to check a server for a specific file? I have the address of the server, but I don't know the code to check the server for a file. In case you don't understand here's an example. I want to check the server www.gamedev.net for the file named "BLABLA.BLA", how do I do this? Or what if I only have the IP address of this server?

Thanks in advance

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!