Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
W

wootski

@wootski
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • values of language,computer name and user name
    W wootski

    char RemoteFileName[60]; TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { // We got the name, set the return value. strcpy(RemoteFileName,chrComputerName); you may need to #include

    C / C++ / MFC windows-admin

  • Winwock Get Request Help
    W wootski

    Hello, I was reading one of the tutorials on your site and thought I would try code something that could download files off the internet. However, when I try to download large files or ones that use weird characters the files become corrupt and do not work. This is the case for .rar,.zip and many other formats. Further, I am unable to get information from .asp sites at all!? Any help would be greatly appreciated. g++ ws.cpp -lws2_32 Note: Include files altered to work with this forum, missing "<" #include winsock2.h> #include ws2tcpip.h> #include stdio.h> #include iostream> #include fstream> using namespace std; int main() { char servername[40] = "members.myserver.com"; char filepath[40] = "/username/file.rar"; char filename[20] = "downloadedfile.rar"; char buff[512]; struct hostent *hp; unsigned int addr; struct sockaddr_in server; int y; WSAData wsaData; // Initialize Winsock int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); return 1; } SOCKET conn; conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(conn==INVALID_SOCKET) return 0; if(inet_addr(servername)==INADDR_NONE) { hp=gethostbyname(servername); } else { addr=inet_addr(servername); hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET); } if(hp==NULL) { closesocket(conn); return 0; } server.sin_addr.s_addr=*((unsigned long*)hp->h_addr); server.sin_family=AF_INET; server.sin_port=htons(80); if(connect(conn,(struct sockaddr*)&server,sizeof(server))) { closesocket(conn); return 0; } sprintf(buff,"GET %s\r\n\r\n",filepath); send(conn,buff,strlen(buff),0); ofstream file; file.open(filename); while(y=recv(conn,buff,512,0)) { file << buff; //gets some slight errors } file.close(); closesocket(conn); WSACleanup(); return 0; } Thanks! =D

    C / C++ / MFC c++ com sysadmin help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups