Wilfried Mestdagh wrote:
> Hello Olivier,
>
>   
>> I can't use LineMode, what is transferred is purely binary.
>>     
>
> See http://wiki.overbyte.be/wiki/index.php/Sending_and_receiving_data
> that discusses some possible data transfer modes.
>   

Thanks for that link. My code is for a transport layer that should not 
make any assumption on what is transferred, so binary mode without any 
line buffering is the way to go for me.

>> buffer and rely on the one from the API itself.
>> I tried it, it works fine, but is it be a "nice" thing to do? Are there
>> any risks associated with this behavior?
>>     
>
> if you only receive if you have complete data packet instead of
> receiving every time winsock want to give you a partial data packet then
> you design an untested situation because TWSocket is designed to deliver
> data every time winsock has data. so not by design and not tested seems
> discouraged to me.
>
> but also if you do so and only receive if complete data is received,
> then how do you know data is complete ?  I mean you can only know by
> examing the data so by receive it ?
>   
It's the packets received before that indicate the length and all that, 
but my layer does not know it. It is just being requested for N bytes to 
be put in a given buffer. So if N is greater than what is available, 
there is a problem anyway.

> So I think using your own buffer is the best thing to do.
>   
Yes, that's what I did in the end, but I reduced the size of this buffer 
(1024 instead of 2048) as most data transfers are for small chunks (less 
than 100 bytes). This way I don't use too much memory per client 
connection. I'll do some benchmarking on this, but I don't see any 
reason why I would need a bigger buffer for my layer, per client connection.
In the end, I do use wsoNoReceiveLoop anyway as the message pump must 
continue working even if there is more data for one socket. This way it 
does not stalls the other sockets associated to the message pump.

Thanks for the help, all is fine now.
Regards
Olivier
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to