Hi all
I have two applications that make use of DS socket solution. This applications interact sending lots of objects. Instances that, making to them a 'binaryStoreBytes size' gives you a considerable number (from 115 to 700000 ). Abstract: a TheClient object is receivig lots of objects through it's serverSocket because it hooked the event dataRead to send onDataRead and extract the incoming object. This object had a problem when receive objects. If from the socket we have a trigger for this client, the onDataRead message can came even when the client is deserializating the previous one. So we had a problem when that happens. Anybody have suggestions? Here is a portion of code: _______________________________________ TheClient>>onDataReady self dataToRead. _______________________________________ TheClient>>dataToRead self reading ifTrue:[ self error:'We are receiveing a dataToRead before finish the previous one.']. self reading: true. incomingObject := self serverSocket receive. self reading: false. I have received the error many times so... what is really happening here? serverSocket receive isn't blocking? I've tried this too: _______________________________________ TheClient>>dataToRead self serverSocket hasInput ifTrue:[ self reading ifTrue:[ self error:'We are receiveing a dataToRead before finish the previous one.']. self reading: true. incomingObject := self serverSocket receive. self reading: false ]. this one prevents that you send the STBInFiler to a sure failure but you loose at least one notification of the dataToRead from the hooked message, so you will have a hasInput that answers true but nobody to send you a dataToRead again to extract the following object. I'll apreciate suggestions Seb |
Seb,
> Abstract: > a TheClient object is receivig lots of objects through it's serverSocket > because it hooked the event dataRead to send onDataRead and extract the > incoming object. > This object had a problem when receive objects. > If from the socket we have a trigger for this client, the onDataRead message > can came even when the client is deserializating the previous one. So we had > a problem when that happens. Appologies in advance if I'm _way_ off on this (possible), but, it sounds to me as though you are getting data that's been "broken up by the network". Stream sockets guarantee (essentially) that they won't scramble the order of data, and that they won't tell you they succeeded when they didn't - they might not tell you they failed though (but I don't think that's your problem). Large blobs will not be sent as one block; instead, they will arrive as smaller blocks, but, in the right order. I'm guessing that you are having one send get turned into multiple reads, each of which is triggering an event. You should be able to simply point an STBInFiler at the socket's read stream, but, do so on other than the GUI thread, and just let it block until it gets the data it needs. You will have to pay attention to thread synchronization issues of course, and you might have to become acquainted with #forkMainIfMain if you need to involve the GUI thread in any of the waiting. Does that help? Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
Free forum by Nabble | Edit this page |