Hello Francois,

Is there a way to tell the number of bytes available without
actually retrieving the data? At some point I'd like to know
if there is data available but do not want to actually remove
the data from twsocket's buffer. This is because I want to
open a remote socket and make sure it's in wsConnected state,
then I'll retrieve data and send it through the remote socket.
The idea is to skip OnDataAvailable if no data is available,
and when there is some data, connect to a remote server, skip
more OnDataAvailable until the remote socket is connected, then
actually retrieve data and send the data via remote socket.

Or is it a bad idea to do so?

An alternative way is to call Receive() and allocate memory
and cache the data into memory before remote socket is available.
But is this necessary?

-- 
Best regards,
Jack

Sunday, January 22, 2006, 4:24:57 AM, you wrote:

> Instead of ReceiveStr, call Receive to be able to get winsock.recv return
> code. This return code is -1 if some error occure, 0 is remote has 
> gracefully closed or a positive integer to telle how many bytes you have
> received.

> Usually you can safely ignore any OnDataAvailable where Receive return <= 0.

> --
> Contribute to the SSL Effort. Visit
> http://www.overbyte.be/eng/ssl.html
> --
> [EMAIL PROTECTED]
> http://www.overbyte.be



> ----- Original Message ----- 
> From: "Jack" <[EMAIL PROTECTED]>
> To: <twsocket@elists.org>
> Sent: Sunday, January 22, 2006 5:25 AM
> Subject: [twsocket] OnDataAvailable called before shutdown with no data


>> Hello Francois and all,
>>
>> I use telnet as client to connect to a twsocketserver,
>> after connecting to it, without sending any data from
>> the client (do not type anything in telnet) I call shutdown(1)
>> on all the client sockets. After this, although there is no
>> data received, the client socket's OnDataAvailable is called.
>> But if I call ReceiveStr(), I got data length 0.
>>
>> Is this a bug - because there's actually no data received?
>>
>> If it's not a bug, is there a way to tell if there is any
>> data before calling ReceiveStr() or Receive()?
>>
>> -- 
>> Best regards,
>> Jack
>>
>> -- 
>> 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 


-- 
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