C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 06-29-2006, 06:04 AM   #1
Eager young mind
 
Join Date: Jun 2006
Posts: 342
data curroption

I have written client/server progs to transfer files . Through this program, I am now able to transfer files larger than 1 MB from my machine to any remote machine where the client program is running without any problem..


The other requirement of the program is to read a file that exists in hte remote machine.. I have used the same concept even for that code and i have traced it many times to find any pit-falls, but I am not able to transfer files greater than 5000 bytes without the data being curropted..
I also noted these things..
1 . the data in the packets that is being sent from hte remote machine is valid, thats not the case after I receive them here for the final few packets
2. also, the numbers returned by send() and recv() match for a large number of packets sent , the mismatch occurs in the last few packets..
By curropted ,I mean some sections of the file getting repeated right at the end , or after the actual file has been transfered, a part of the file also gets added.
The lan is a standard one, I can do my usual ftp and telnet stuff.

I cud have posted the code , but its quite bulky..
Has anyone faced this problem before, please help
kris.c is offline   Reply With Quote
Old 06-29-2006, 06:48 AM   #2
Eager young mind
 
Join Date: Jun 2006
Posts: 342
i would like to add one more thing here :
I was instructed break up large files into chunks of 1000 bytes and then use the send() iteratively ..
only in the in the last packet, the send() and recv() functions return different values..
kris.c is offline   Reply With Quote
Old 06-29-2006, 11:18 AM   #3
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,650
Deja-vu again and again?
send() and recv() functions
file transfer across network

1. Are you using a TCP or UDP connection?

2. Do you send the length of the file first, then the contents of the file?
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 06-30-2006, 01:24 AM   #4
Eager young mind
 
Join Date: Jun 2006
Posts: 342
forget about that ,i cud fix it..
kris.c is offline   Reply With Quote
Old 06-30-2006, 07:01 AM   #5
Carnivore ('-'v)
 
Hunter2's Avatar
 
Join Date: May 2002
Posts: 2,866
Quote:
By curropted ,I mean some sections of the file getting repeated right at the end , or after the actual file has been transfered, a part of the file also gets added.
If the answer to (2) is no, perhaps you're outputting the receive-buffer before checking the error status of recv(). Or, maybe you're assuming that (packet_size) bytes have been received instead of checking recv()'s return value. That would lead to (in the first case) the last packet being repeated, or (in the second case) a segment of the second-last packet being repeated.

*EDIT: Actually, the second case would lead to random unpredictable bits of data strewn all throughout your output, and a predictable segment of the second-last packet being appended to the last.

Judging from the previous threads, this is *probably* the problem.

*EDIT2: Actually, the 'predictable' segment will *not* occur if:
(filesize % buffersize) == (unpredictable_bytes % buffersize).
See if you can figure out why.
__________________
Just Google It. √

(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Last edited by Hunter2; 06-30-2006 at 07:13 AM.
Hunter2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
xor linked list adramalech C Programming 23 10-14-2008 10:13 AM
brace-enclosed error jdc18 C++ Programming 53 05-03-2007 05:49 PM
singly linked circular list DarkDot C++ Programming 0 04-24-2007 08:55 PM
Program Crashing Pressure C Programming 3 04-18-2005 10:28 PM
Ask about how to use startdoc(), startpage() to print data on paper imediately. ooosawaddee3 C++ Programming 1 07-31-2002 11:35 AM


All times are GMT -6. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22