473,395 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# Socket.Send removing carriage return

I am using an FtpClient.cs that someone else created and when I'm uploading (it uses a Socket) a file a carriage return is getting deleted when the file appears on the ftp location. Normally this wouldn't be a huge issue but this file is encrypted and by losing this byte it's unable to decrypt successfully.

Example of section where it errors out from original file (just file bytes):
E6C5C22DB57E0D0A78E5936259DCF4D8

Example of section where it errors after file is uploaded to ftp host(just file bytes)::
E6C5C22DB57E0A78E5936259DCF4D814

Here's the part of the upload code.
//input is a FileStream, bytes is an int, and buffer is a byte[], and cSocket
//is new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

//I debugged here and the values are correct in the buffer, but
//as soon as it sends the byte is getting removed.

while ((bytes = input.Read(buffer, 0, buffer.Length)) > 0)
{
cSocket.Send(buffer, bytes, 0);
}

My question is there a SocketFlag that will allow to not remove this particular carriage return, I couldn't see any when I'm glancing through socketflags...
Jan 23 '08 #1
2 3918
Plater
7,872 Expert 4TB
The carriage return removal sounds like it is trying to convert the file to ASCII. Particularily converting from DOS format to UNIX format (DOS uses \r\n while UNIX uses just one of them)
OR at very least it's doing a ReadLine() somewhere.
Make sure you that the server thinks you are sending the files as binary, that you want to maintain DOS format(shouldn't matter if you upload 'as binary') and make sure there is no calls to anything like ReadLine()
Jan 23 '08 #2
Thanks a lot! What you said really helped, so here's the solution... I needed to send this command first, kinda new to FTP so i didn't catch that. THANKs!

this.sendCommand("TYPE " + "I", 10);
Jan 23 '08 #3

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

Similar topics

4
by: Scott Robinson | last post by:
I have been having trouble with the garbage collector and sockets. Unfortunately, google keeps telling me that the problem is the garbage collector ignoring dead (closed?) sockets instead of...
6
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: ...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
4
by: SpreadTooThin | last post by:
client: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("192.168.1.101", 8080)) print 'Connected' s.send('ABCD') buffer = s.recv(4) print buffer s.send('exit')
6
by: shajias | last post by:
Hi, I am having a xml code like this <name> I am having a carriage return here. Second line with carriage return. This is the last line. </name>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.