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. Does anyone know this error??

Does anyone know this error??

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelpquestionlounge
3 Posts 2 Posters 1 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.
  • P Offline
    P Offline
    Pett
    wrote on last edited by
    #1

    Hi! I'm still working on my assignment to modify my chat program to have the capability to transfer files as well as messages. I put a button on the client side, and when the person clicks on it, the file dialog box is supposed to open, and the person can choose the file to send. I get the dialog box, the program gets the file path.. reads the file ok.. and now it is being sent to the server.. (I've made progress!):) However, the server gives an error, "An attempt was made to access an unnamed file past its end". :confused: If anyone knows what the error means exactly, or can give any suggestions about it... please respond. Thank you.. :)

    A 1 Reply Last reply
    0
    • P Pett

      Hi! I'm still working on my assignment to modify my chat program to have the capability to transfer files as well as messages. I put a button on the client side, and when the person clicks on it, the file dialog box is supposed to open, and the person can choose the file to send. I get the dialog box, the program gets the file path.. reads the file ok.. and now it is being sent to the server.. (I've made progress!):) However, the server gives an error, "An attempt was made to access an unnamed file past its end". :confused: If anyone knows what the error means exactly, or can give any suggestions about it... please respond. Thank you.. :)

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      How are you reading and writing the file? If you are chopping it up and sending it you may be reading into the file past its end same as when you receive the file.. could you post some code?

      P 1 Reply Last reply
      0
      • A Anonymous

        How are you reading and writing the file? If you are chopping it up and sending it you may be reading into the file past its end same as when you receive the file.. could you post some code?

        P Offline
        P Offline
        Pett
        wrote on last edited by
        #3

        Thank you so much for replying to me.:) The following is my send code when the button is clicked. I found most of it on this site: void CMainFrame::OnSFile() { MessageBox("File Transfer"); CSocket cSocket; cSocket.Create(); //cSocket.Connect((LPCTSTR(m_strServerIP)),m_iFTPort); cSocket.Connect("127.0.0.1", 700); csocketfile sf(&cSocket); CArchive ar(&sf, CArchive::store); /*code for CFileDialog goes here*/ static char BASED_CODE szFilter[] = "All Files (*.*)|*.*||"; CString strPath; CFileDialog m_ldFile(TRUE,".*","*.*",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter); // Initialize the starting directory //m_ldFile.m_ofn.lpstrInitialDir = _T("C:\\"); // Show the file open dialog and captures the result //if IDOK if (m_ldFile.DoModal() == IDOK) { strPath = m_ldFile.GetPathName(); CFile myFile(strPath, CFile::modeRead | CFile::typeBinary); //get file info DWORD length = myFile.GetLength(); char *data = new char[length]; myFile.Read(data, length); //send it across ar << myFile.GetFileName(); ar << length; ar.Write(data, length); delete[] data; myFile.Close(); } } -------------------------------------------------------------------------- On the server side, I've put this as the receiving code. Maybe I've put it in the wrong place?:~ There is a void CClientSocket::OnReceive(int nErrorCode) which is an overrided method from the CSocket class. So basically whenever the socket receives something, it kicks off the OnReceive code. I've put it there. Also, in my Send code, there is a line commented off, and replaced with a hardcoded statement. Before I did that I was getting another error, "An unknown error occurred while accessing an unnamed file" I'm going to try changing around a few things, but if you have any suggestions on thoughts on this, please let me know. Thank you so much.

        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