Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages
Started by Patrick FAURE
Sat, 19 Jun 2004 05:02
Re : Image and network problem - the answer !
Author: Patrick FAURE
Date: Sat, 19 Jun 2004 05:02
Date: Sat, 19 Jun 2004 05:02
17 lines
1271 bytes
1271 bytes
Hi,
I found the solution.
The problem was in :
Socket->ReceiveBuf(OFFSETBYTES(DataComplete->Memory, oldSize),
incomingSize);
where the number of bytes read by ReceiveBuf is not always
equal to incomingSize.
Here is the solution :
int readBytes = Socket->ReceiveBuf(OFFSETBYTES(DataComplete->
Memory, oldSize), incomingSize);
DataComplete->Size = oldSize + readBytes;
So there is no hole in received data stream.
My image appears correctly in TImage.
Patrick
Re: Image and network problem - the answer !
Author: Remy Lebeau (TeamB)
Date: Sat, 19 Jun 2004 05:57
Date: Sat, 19 Jun 2004 05:57
27 lines
2237 bytes
2237 bytes
"Patrick FAURE" <DidactSoft@aol.com> wrote in message news:40d3c8ef$1@newsgroups.borland.com... > The problem was in : > Socket->ReceiveBuf(OFFSETBYTES(DataComplete->Memory, oldSize), > incomingSize); > where the number of bytes read by ReceiveBuf is not always > equal to incomingSize. If the incomingSize is obtained via ReceiveLength() just prior to calling ReceiveBuf(), then ReceiveBuf() is guaranteed to return that many bytes in a single call, since the whole purpose of ReceiveLength() is to determine how many bytes have been received and buffered and are ready for immediate reading. The only way ReceiveBuf() could not return the full number of bytes in a single call under that scenerio is if there is an error on the socket, or maybe if there is a LOT of data buffered and the socket chooses not to return it all in a single call for whatever reason (unlikely, though). In any case, it is very common with socket programming for ReceiveBuf() to not return the full bytes in general, so you should always be taking that into account, calling ReceiveBuf() in a loop until all of the expected data has been received in full. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads