Re: [xSocket-develop] Processing large data blocks: comment and question.
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-01-10 15:53:50
|
Hi Simon, thanks for your feedback concerning the documentation. I'm currently updating xSocket's documentation/homepage. Your question should (hopefully) be answered by the updated and not yet released new documentation/homepage: http://xsocket.sourceforge.net/indexNew.html -> see xSocket (core) V2.0-alpha-2 tutorial. If not, don't hesitate to contact me. Gregor 2008/1/10, Simon Ward <si...@tr...>: > > Hi, > > I have just started experimenting with xSocket and I have managed to > create a rudimentary pub/sub system in two days so it is looking good so > far. However, I did have one comment and one question. > > Firstly, I worked out how to handle the case where a large data block > has not arrived yet. I think this could be a bit clearer in the > documentation though because initially I though that I should make the > IDataHandler onData method wait and loop until more data was in the > buffer if I got a buffer underflow. However, I found that the buffer > never got any more data presumably due to your internal locking. I did > eventually work out that the StreamUtils.validate... method actually > works by throwing the BufferUnderflowException that causes that call to > onData to abort; then onData is called again when more data arrives, and > this repeats until the whole block of data has arrived and it can be > processed normally. > > My question is: what happens if a large data block is followed by a > small data block? I presume that the sender will buffer the data so > that the small data block arrives immediately after the large data > block, so the two blocks arrive as a continuous stream. My handler will > keep attempting to read the large data block until it has arrive. > However, in the last call to onData, which can finally real the large > data block, the buffer may also contain the entire small data block > too? I assume that onData will only be called when more data arrives at > the socket. Therefore, if the small data block has already arrived, > onData will not be called again? Do I need to check for more data in > the buffer with getNumberOfAvailableBytes() and then have onData > recursively call itself, or will your framework automatically call > onData again if my handler returns with unread data in the buffer? > > Regards, > Simon. > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > xSocket-develop mailing list > xSo...@li... > https://lists.sourceforge.net/lists/listinfo/xsocket-develop > |