473,657 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange artifacts in recieved file

1 New Member
Hi

I'm working on a simple FTP server implementation but I've run into a strange problem.

I use this function to recieve:

Expand|Select|Wrap|Line Numbers
  1. def stor(self):
  2.    f = open('test', 'w')
  3.    while 1:
  4.       data = self.pasvsocket.recv(1024).replace('\r\n', '\n')
  5.       if not data:
  6.          break
  7.       f.write(data)
  8.    f.close()
  9.  
I use a simple large test file with 49999 lines with numbers going from 1 and incrementing each line to 49999. Here comes the strange thing. When this file is transmitted by the standard linux ftp program artifacts appears. Viewed in a editor (vim) these artifacts are the "^M" often seen. They appear with exactly 512 lines in between at the end of the line. Using 4096 as the buffer size the number is 2048 - hmm stange!

I guess that I'm receiving in the wrong way... Can anyone catch the problem?

Thanks :)
Mar 25 '07 #1
1 1083
ghostdog74
511 Recognized Expert Contributor
Hi

I'm working on a simple FTP server implementation but I've run into a strange problem.

I use this function to recieve:

Expand|Select|Wrap|Line Numbers
  1. def stor(self):
  2.    f = open('test', 'w')
  3.    while 1:
  4.       data = self.pasvsocket.recv(1024).replace('\r\n', '\n')
  5.       if not data:
  6.          break
  7.       f.write(data)
  8.    f.close()
  9.  
I use a simple large test file with 49999 lines with numbers going from 1 and incrementing each line to 49999. Here comes the strange thing. When this file is transmitted by the standard linux ftp program artifacts appears. Viewed in a editor (vim) these artifacts are the "^M" often seen. They appear with exactly 512 lines in between at the end of the line. Using 4096 as the buffer size the number is 2048 - hmm stange!

I guess that I'm receiving in the wrong way... Can anyone catch the problem?

Thanks :)
just a guess, maybe this line did not work
Expand|Select|Wrap|Line Numbers
  1. ...
  2. data = self.pasvsocket.recv(1024).replace('\r\n', '\n')
  3. ...
  4.  
you might want to check the last character of "data" by doing a print
Expand|Select|Wrap|Line Numbers
  1. ..
  2. print "last char of data is " % data[-1], len(data[-1])
  3. ...
  4.  
OR another way to do it is, after recving the whole file, do another function to remove ^M. ^M are newlines..
Mar 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2869
by: Muppy | last post by:
I've created a page with a form to upload files: <h1>Upload di un file</h1> <form enctype="multipart/form-data" method="post" action="do_upload1.php"> <p><strong>File da trasferire:</strong><br> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input type="file" name="img1" size="30"> </p> <p> <input type="submit" name="submit" value="Upload File">
1
1216
by: John McD | last post by:
I'm trying to have a method in a page which checks the database for user's email. The query populates the variable strEmailTo and then sends the email: MailMessage msg = new MailMessage(); msg.To = strEmailTo; msg.From = strEmailFrom; msg.Subject = "whatever"; msg.Body = "whatever";
6
1940
by: Werner Partner | last post by:
I use a page created by php. It should show two pictures of a person an a short text. If there are no picture, nothing is shown, if there is no text, nothing is shown. There a about 20 persons, some of them ghave two pictures, some of them one or none. Some of them have text. Every person has an indexword as for instance "meyer", there can be a
31
2610
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
5
1928
by: Archer | last post by:
I was making a role-based authentication but it does't login with correct password. the HttpContext.Current.User recieved in Global.asax is always null. Request.IsAuthenticated is always false. in the cs files, i write the code below protected void SubmitBtn_Click(Object sender, EventArgs e) {
1
1351
by: BobAchgill | last post by:
I had a setup install fail on me for some reason which is not clear. I had to kill the install because it got stuck... I killed it using Windows Task Manager. So now I can not make another setup install file that will run because the system thinks there is already a install in process. How can I clean out the artifacts of the previously failed install from my computer?
20
5375
by: newbie | last post by:
Hi all, http://www.aswin.be/nictransfer.JPG How can I get these numbers with VB.NET ? I thought somewhere in WMI but I can't find them. Thank you, Aswin
2
19997
by: P | last post by:
Hi all, I'm trying to run the following code taken from http://blogs.ittoolbox.com/database/technology/archives/006045.asp# select substr(tablespace_name,1,30) as "Tablespace Name", case (tablespace_type) when 0 then 'DMS' else 'SMS' end as "Type",
7
2742
by: sreehari | last post by:
Hi All, I have this problem, I have developed a Master - Slave kinda appliacation , were the slave is generally a device.when i broadcast a message from my application, the Device seems to recieve the message and responds correctly, and replies with a broadcast frame. Here is where i face the problem, what happens is that my application seems to Time out even if Ethereal ( Network Sniffer ) detects and shows all the frames that were
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.