LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-17-2006, 04:40 PM   #1
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 705

Rep: Reputation: 30
exchange xml messages from java.nio.Channels


Hi,
i am writing an application; a simulator of a p2p network. I have decided that the best way to go on is for the peers to exchange xml messages using nio.Channels. I have limited experience in both. The question is the following:
Say i have ByteBuffer of fixed size (say bbuffer) for reading the incoming xml messages from the source Channel. A bbuffer, after reading the channel, could contain any real number of messages, for example:
-0.x messages, because a message could not fit
-1.7 messages, because the first message does fit and we read 0.7 from the second one.
-etc.

All these are just series of bytes; how do i know where the first message stops, where the second starts and if the entire messages -all their bytes- are stored in the byte buffer? What if i reach the end of the buffer and find out, that not the entire message is contained there? Any help appreciated.

Thanks
 
Old 12-17-2006, 05:19 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
It sounds like you are limiting the allowed message size. How come?
 
Old 12-17-2006, 06:24 PM   #3
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 705

Original Poster
Rep: Reputation: 30
I am not limiting the allowed message size; it can be of any size. The ByteBuffer object is of fixed size (ByteBuffer bbuffer=ByteBuffer.allocate(aFixedSize)). ANY number of messages can fit inside the bbuffer.
 
Old 12-17-2006, 08:19 PM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Hmm...ok. I don't do much in the way of network-programming in Java (I keep to Lisp for that).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Why StAX'ing up XML is the new Java Standard LXer Syndicated Linux News 0 12-16-2006 01:21 PM
Java code to compare XML like ExamXML alapick Programming 1 06-29-2006 05:43 AM
onverting database rrelational data into xml using java anirudh Programming 0 03-23-2005 07:05 AM
java and xml infected Programming 2 11-26-2004 02:28 AM
HTML / RICHTEXT messages Stripped from Exchange to Sendmail... Vince0000 Linux - General 0 10-23-2003 12:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration