?
Solved

File Sending Problem

Posted on 2003-02-21
9
Medium Priority
?
233 Views
Last Modified: 2010-04-01
I using Pocket PC 2002(Client) Destop Windows 2000 (Server). I am trying to send a file(sound file) from the server to the client through WIRELESS. Aftering sending, my file on the Pocket PC cannot be used. But..

When i try it on a Desktop to Desktop(also wireless), the file can be use.

I also tried sending a workable file from the Pocket PC 2002 to Desktop. It is also workable. So no problem with my codes i think.

I'm using CSocket and C++ for my coding.

Any Help or Advice is appreciated.
THnaks
0
Comment
Question by:Students
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Author Comment

by:Students
ID: 7998165
What i found out is that: i think i miss reading the first byte.

I tested out by sending a txt file to the PDA and retrieve it again through active sync. the first letter of the txt file is missing.

Can someone check my algorith.

int nBytesRead = sockClient.Receive(&dataLength, 4); // Getting the data length send from the server//
               
          byte* receivedData = new byte[dataLength];

          nBytesRead = 0;

          long dataLengthTemp = dataLength;

          MessageBox(_T("Checking data integrity!!!"));

          while (dataLength != nBytesRead) {
               int dataReadLen = sockClient.Receive(receivedData + nBytesRead, dataLength - nBytesRead);
               nBytesRead += dataReadLen;
          };
     
          sockClient.Receive(receivedData, dataLength);

          CFile destFile(readFile, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
         
          destFile.Write(receivedData, dataLength);

0
 

Author Comment

by:Students
ID: 7998282
Sorry for the trouble.. I have solve this problem thanx
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7998386
You are not checking for a potential error in the Recieve call.  It can return SOCKET_ERROR, which I believe equates to -1

That loops looks a little funny.  I'd just use:

byte* p= receivedData;
int nBytesLeft= dataLength;
while( nBytesLeft > 0 ) {
        int nActual= sockClient.Receive(p,nBytesLeft);
        if (nActual == SOCKET_ERROR || nActual == 0) {
             // handke the error
        }
        nBytesLeft -= nActual;
};
(note: I did not verify the above code).  

If that is not the problem, then show the code that is sending the data.

-- Dan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:akshayxx
ID: 7998681
u can ask for refund of points on community support
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8000676
What was the problem?
-- Dan
0
 

Expert Comment

by:modulo
ID: 8115159
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/Q_20546050.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8115879
There would be much more value in the PAQ if Students would take a few moments to describe what he did to solve the problem.  Lacking that, I'd recommend a simple delete.

Students, can you describe what you did to solve this problem?  Thanks!

-- Dan
0
 

Author Comment

by:Students
ID: 8125846
When i send a txt file over .. the first text was missing, so i thought that i started reading at the wrong time.

sockClient.Receive(receivedData, dataLength);

when i replaced the above statemtent with

sockClient.Receive(receivedData+datalength+1, dataLength);

the space will moved to the length of the file + 1

         

0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 8159217
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question