Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

File Sending Problem

Posted on 2003-02-21
9
Medium Priority
?
239 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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

564 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