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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. about TransmitFile

about TransmitFile

Scheduled Pinned Locked Moved C / C++ / MFC
helpjsontutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yingkou
    wrote on last edited by
    #1

    I want to use API TransmitFile to build a C/S structure ,who can give me an example.I have written a program but client program has bug,client codes as below: UINT ClientThread(LPVOID lv) { SOCKET s=(SOCKET)lv; CFile f; bool IsOpen=false; char buf[1024*128]="";int count=0; while (true) { buf[0]='\0'; int ret=recv(s,buf,sizeof(buf),0); if(SOCKET_ERROR == ret) { CString s; s.Format("%d",WSAGetLastError()); AfxGetMainWnd()->SetWindowText(s); break; } else { CString str(buf,ret); int i=str.Find(':'); if(-1 != i) { if(f.Open(str.Right(str.GetLength()-i- 1),CFile::modeCreate|CFile::modeWrite) == 0) break; IsOpen=true; } else if("FileTranferOver" == str) break; else if(IsOpen) { try { f.Write(buf,ret); } catch (...) { str.Format("%d",GetLastError()); MessageBox(NULL,str,"Error",MB_OK); } } else continue; count+=ret; } } if(IsOpen) f.Close(); CString str1; str1.Format("%d",count); AfxGetMainWnd()->SetWindowText(str1); return 0; }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

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