Re: send-receive using CSocket



In addition to all of Josh's comments...

Be aware that if you send a buffer, that the receive does not receive the same information
length as was sent. For example, if you send 8K bytes, an 8K receive may or may not
receive 8K bytes; it may receive many fewer. It is your responsibility to reassemble the
bits on the other side.

TCP only guarantees that you will receive every byte sent, in order, with no errors and no
duplicates, OR you will get an error notification on both sides that there is a
communications problem. It does not guarantee that the receiver receives packets of the
same size that were sent, and in general this will *never* be true. So you will receive
the data in little pieces (if you're at the end of a SLIP connection, possibly in 256-byte
pieces!) of varying and unpredictable length.
joe

On 28 Nov 2005 12:30:33 -0800, "Josh McFarlane" <darsant@xxxxxxxxx> wrote:

>mayara wrote:
>> hi everyone .i`m doing a project for capturing the
>> desktop image & sending it from server to client " i convert it to DIB
>> then send the buffer of DIB using TCP " when i try to do a
>> StretchBIBits on client the image is not so complete it has some
>> missing pieces
>> think the problem may be in my send-receive code.can u help me with a
>> strong and reliable send-receive code??
>
>First off: You may want to stop using CSocket, as it has problems. Take
>a look at CAsyncSocket and try using that.
>
>Second off: Is your image a constant size buffer? If not, how do you
>know the exact dimensions of the image?
>
>What kind of package are you transmitting across the buffer? Just the
>image buffer? Or are you also transmitting height, width, color
>information, etc. If you are transmitting more information, are you
>receiving all of it, or just part of it, or is it invalid?
>
>Josh McFarlane
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: send-receive using CSocket
    ... > desktop image & sending it from server to client " i convert it to DIB ... > strong and reliable send-receive code?? ... Is your image a constant size buffer? ... What kind of package are you transmitting across the buffer? ...
    (microsoft.public.vc.mfc)
  • Re: Performance/lockup issues with FreeBSD as a router
    ... > NICs will stop transmitting traffic. ... "no buffer space available" appears often when the buffer is used so ... because if your connections are good why the buffer should be used? ... I guess that probably your Nics, ...
    (freebsd-performance)
  • Re: write() only sends 16 chars to serial port?
    ... serial driver fills the tx FIFO with 16 bytes and starts it ... transmitting. ... but I'll probably add the tcdrain for safety. ... the buffer when I do it, but I don't know if that's guaranteed ...
    (comp.os.linux.development.apps)
  • Re: CStdioFile* file = internet_session.OpenURL
    ... Fundamental errors here. ... If is safe to assume that the bytes read will be some arbitrarily small number, ... considerably LESS than the buffer size on most days. ... Joseph M. Newcomer [MVP] ...
    (microsoft.public.vc.mfc)
  • Re: viewing files in a directory
    ... directory, it is more likely you will have a CString argument, and again the TCHAR array ... >> In addition, in the example shown, there is no reason to copy the string ... >> so you can give the buffer address. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)