473,378 Members | 1,434 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,378 software developers and data experts.

WriteLine and Linebreak

Hey,

I have following struct:

struct Packet
{
string Command;
byte[] data;
}

I want to send this trough an open Network connection.
I serialize it first and remove all linebreaks in the XML data.
When I send it using WriteLine(strXML), what happens with linebreaks in the
bytearray?
Does it only send the content til the linebreak?

thx
Nov 16 '05 #1
4 2604
Dirk,

You shouldn't be modifying the XML data. Rather, you should tranform it
to contain the linebreaks (using something like base64 or something).

Or better yet, why not serialize to a binary format and then encode
using base64? You don't have to worry about linebreaks then.

Why are you removing the linebreaks at all? Is the message you are
sending dependent on linebreaks? If you have dynamic content in your
messages, then you need to have some method of accounting for the fact that
the dynamic content could have linebreaks itself. Modifying the content is
a bad idea, because then you can end up with errors due to the
transformation (plus the fact that you are modifying it is a generally bad
idea). If anything, transform it to a format that doesn't have line breaks,
and send that.

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:O%****************@TK2MSFTNGP11.phx.gbl...
Hey,

I have following struct:

struct Packet
{
string Command;
byte[] data;
}

I want to send this trough an open Network connection.
I serialize it first and remove all linebreaks in the XML data.
When I send it using WriteLine(strXML), what happens with linebreaks in
the bytearray?
Does it only send the content til the linebreak?

thx

Nov 16 '05 #2
can you post some example code, please?
I'm from germany and not sure if had understand it right :)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:O9*************@TK2MSFTNGP10.phx.gbl...
Dirk,

You shouldn't be modifying the XML data. Rather, you should tranform
it to contain the linebreaks (using something like base64 or something).

Or better yet, why not serialize to a binary format and then encode
using base64? You don't have to worry about linebreaks then.

Why are you removing the linebreaks at all? Is the message you are
sending dependent on linebreaks? If you have dynamic content in your
messages, then you need to have some method of accounting for the fact
that the dynamic content could have linebreaks itself. Modifying the
content is a bad idea, because then you can end up with errors due to the
transformation (plus the fact that you are modifying it is a generally bad
idea). If anything, transform it to a format that doesn't have line
breaks, and send that.

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:O%****************@TK2MSFTNGP11.phx.gbl...
Hey,

I have following struct:

struct Packet
{
string Command;
byte[] data;
}

I want to send this trough an open Network connection.
I serialize it first and remove all linebreaks in the XML data.
When I send it using WriteLine(strXML), what happens with linebreaks in
the bytearray?
Does it only send the content til the linebreak?

thx


Nov 16 '05 #3
Dirk,

Instead of transforming the XML, why not call the static ToBase64String
method on the Convert class, that way, you can get a section of text to send
with no line breaks.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:uK*************@TK2MSFTNGP12.phx.gbl...
can you post some example code, please?
I'm from germany and not sure if had understand it right :)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:O9*************@TK2MSFTNGP10.phx.gbl...
Dirk,

You shouldn't be modifying the XML data. Rather, you should tranform
it to contain the linebreaks (using something like base64 or something).

Or better yet, why not serialize to a binary format and then encode
using base64? You don't have to worry about linebreaks then.

Why are you removing the linebreaks at all? Is the message you are
sending dependent on linebreaks? If you have dynamic content in your
messages, then you need to have some method of accounting for the fact
that the dynamic content could have linebreaks itself. Modifying the
content is a bad idea, because then you can end up with errors due to the
transformation (plus the fact that you are modifying it is a generally
bad idea). If anything, transform it to a format that doesn't have line
breaks, and send that.

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:O%****************@TK2MSFTNGP11.phx.gbl...
Hey,

I have following struct:

struct Packet
{
string Command;
byte[] data;
}

I want to send this trough an open Network connection.
I serialize it first and remove all linebreaks in the XML data.
When I send it using WriteLine(strXML), what happens with linebreaks in
the bytearray?
Does it only send the content til the linebreak?

thx



Nov 16 '05 #4
Check out Synapse for C#
You can simply serialize into a memorystream and use the sendstream method,
then use recvstream on the other side.
You can get the Synapse TCP assembly at
http://groups.yahoo.com/group/synalist/ in the files area.

You can also do readstring and sendstring without the overhead of the C#
networkstream or the streamwriter/reader classes.

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:O#**************@TK2MSFTNGP11.phx.gbl...
Hey,

I have following struct:

struct Packet
{
string Command;
byte[] data;
}

I want to send this trough an open Network connection.
I serialize it first and remove all linebreaks in the XML data.
When I send it using WriteLine(strXML), what happens with linebreaks in the bytearray?
Does it only send the content til the linebreak?

thx

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: nAmYzArC | last post by:
Hi everyone, I'm setting the body of an email using values from a form firstname = bob lastname = dole ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname ...
2
by: Unemployed VC++ guy | last post by:
It seems that there is basically no difference between the Console.Write() & String.Format(), other than the output being sent to the console output stream instead of a string. Is this accurate? ...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
0
by: Howard Kaikow | last post by:
I have never seen WriteLine fail to produce a NewLine, at least, not until now: I was playing with an example given on pages 51-52 of the book "A Visual Basic 6 Programmer's Toolkit". The book...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
2
by: Georg Weiler | last post by:
Hi, I have a form, where the user enters text. After submit, the text is then inserted into a PostgreSQL database. So far, so good. The problem is, that most of my users copy&paste their text...
2
by: djc | last post by:
out of all the overloads that pop up via intellisense for console.writeline() the following one confuses me: Console.WriteLine (string format, params object arg) 1) whats the deal with...
3
by: Michael Hamm | last post by:
My page http://www.math.wustl.edu/~msh210/whatsnew.xml (with XSLT and CSS adding formatting) has a paragraph-type break after "Subscribe to this feed" which, afaIct looking at the source code,...
3
by: Per W. | last post by:
Hi, is it possible to have Literal using linebreaks? If i have a textfile with more than 1 line then Literal take all on one line. /Per W.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.