🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Checking server for a file

Started by
0 comments, last by GameDev.net 24 years, 8 months ago
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

Advertisement
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 somewhereint 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).]


This topic is closed to new replies.

Advertisement