aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes \r\n\r\n gets appended to a message sent via socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "\r\n\r\n gets appended to a message sent via socket" Watch "\r\n\r\n gets appended to a message sent via socket" New topic
Author

\r\n\r\n gets appended to a message sent via socket

Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
I am sending message over a socket from the server to the client. At the client, I find that \r\n\r\n is appended at the end of the message. What is the reason for this?


Thanks and Regards
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

How are you sending the data? Please TellTheDetails.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Rob Prime wrote:How are you sending the data? Please TellTheDetails.


Sorry for that. Here are the details.

Some code snippets of what I am trying to do:


I reduced the problem somewhat by not using PrettyFormat for XMLOutputter, resulting in only \r\n being suffixed instead of \r\n\r\n, but still the problem is very much there.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

I think the problem is in the JDOM XMLOutputter, not in the (Buffered)OutputStream or the Socket. What happens if you print the same document to a text file? Does it also end with two enters?
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Rob Prime wrote:I think the problem is in the JDOM XMLOutputter, not in the (Buffered)OutputStream or the Socket. What happens if you print the same document to a text file? Does it also end with two enters?

Yes indeed that was the case. I prevented XMLOutputter from adding new lines and it worked fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: \r\n\r\n gets appended to a message sent via socket