Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2008

Tip: Looking for answers? Try searching our database.

line feed and carriage return

Thread view: 
belletti.stefano@email.it - 27 Feb 2008 09:17 GMT
I'm a beginner playing with the well known "echoserver" application.
I've "developed" and "built" it in winXP using Netbeans.
It runs fine if the "server" runs in windows: i can telnet to it both
from windows and from linux (kubuntu).
I've distrubted the tar file to the linux machine.
When running the server on linux I can telnet from linux and all it's
fine.
But when I telnet from a winXP client to the server running on
kubuntu, the messages are echoed back to the client (win) with only
the "line feed" as end of line  (that is : without the "carriage
return" that win expects).

The messages are echoed back with:
->pout.println(message_string);
and pout is:
 PrintWriter pout;
 pout = new PrintWriter(connection.getOutputStream(),true);
 ( connection is:     Socket connection;)

The question is: is there a way to have the "end of line" system
independent ?

Thanks for any suggestion or hint.
Gordon Beaton - 27 Feb 2008 11:05 GMT
> The question is: is there a way to have the "end of line" system
> independent ?

Text based protocols typically define EOL as CRLF, regardless of
client or server platform. The important thing is that the server and
all clients are in agreement.

But that means that your components shouldn't rely on PrintWriter to
do the right thing, they should add EOL (as defined by the protocol)
explicitly when transmissing strings.

/gordon

--
Mark Space - 27 Feb 2008 21:06 GMT
>> The question is: is there a way to have the "end of line" system
>> independent ?
[quoted text clipped - 6 lines]
> do the right thing, they should add EOL (as defined by the protocol)
> explicitly when transmissing strings.

That maybe correct.  However, I thought it was normally the client that
was configurable.  The server sends what it wants.  The client decides
whether it should send CRLF or LF based on the user's preferences.

In other words, if your client isn't working right, switch end of line
modes, then it should be good.  That's how I seem to remember using
Telnet with different servers.  It has been a long time since I've
actually used a Telnet app, though.
Gordon Beaton - 28 Feb 2008 06:25 GMT
> That maybe correct.  However, I thought it was normally the client that
> was configurable.  The server sends what it wants.  The client decides
> whether it should send CRLF or LF based on the user's preferences.

I don't think there are any established protocols that actually define
things that way (and why should the user have any preferences in this
specific matter, except that it should work as advertised). Usually
the grammar is pretty specific about what consitutes a line.

However there is certainly no harm in applying the robustness
principle at both ends of every connection: be conservative in what
you do, be liberal in what you accept from others.

/gordon

--
Mark Space - 28 Feb 2008 18:04 GMT
>> That maybe correct.  However, I thought it was normally the client that
>> was configurable.  The server sends what it wants.  The client decides
>> whether it should send CRLF or LF based on the user's preferences.
>
> I don't think there are any established protocols that actually define

I don't think there are either.  I just recalled that Telnet did it one
way, and suggested that also might be appropriate.

Well, for Telnet, I think there really is an established protocol, as
well as a POSIX standard.  But that's different issue.  The OP can come
up with what works best for him. "Works like Telnet" is not a standard.

Thinking about this a bit more, if the server is extended to compensate
for any locale, that could be a lot of resources required on the server
which may have many connections.  If the server implements one standard,
and each client translates to it's own locale, that seems easier to me,
and also taxes the server much less.  Just a couple of nickels....

> things that way (and why should the user have any preferences in this
> specific matter, except that it should work as advertised). Usually
[quoted text clipped - 3 lines]
> principle at both ends of every connection: be conservative in what
> you do, be liberal in what you accept from others.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.