Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-02-20 Thread Wilfried Mestdagh
Hello Jack,

> So when I resume,
> instead of setting the option, I can still use the Resume()
> function to resume notification?

I'm not sure I understeand completely what you ask but:

- Pause will stop notification from winsock. If there is already data
  received then OnDataAvailable will keep on firing for a while until
  you have received.

  After that winsock buffer will fill but no notification. When winsock
  buffer is full then sender will stop sending data.

- Resume will turn notification back on, so filled up receive buffer
  from winsock will fire onDataAvailable again.

- if you set wosNoReceivedLoop and you do NOT receive in OnDataAvaliable
  then it will also not fire again until you call receive. This means
  that you have to call Receive outside the OnDataAvailable to turn it
  on again.

- A combination of both should be working also. You call pause, and when
  you are in paused state you dont want to receive even if there is
  already somethign to receive as you explained in a previous mail. Then
  you do the wsoNoReceivLop;

  I "think" if combine both, and you call Resume that OnDataAvailable
  will fire again without calling Receive outside of it. You can try it
  easely of course. Pleas let us know, this is valuable information.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-02-20 Thread Jack
Hello Francois,

Thanks for the reply. I'll try that. So when I resume,
instead of setting the option, I can still use the Resume()
function to resume notification?

-- 
Best regards,
Jack

Sunday, February 19, 2006, 2:20:54 AM, you wrote:

>> I find that calling pause in OnSessionConnected() is effective.
>> But calling pause in OnClientDataAvailable() does not work.
>> OnClientDataAvailable() keeps getting fired. Any ideas?

> Maybe your socket already received data when you pause it.
> Pause only affect winsock notification. It stops notifications from winsock
> but if data is already in, you have to read it.
> Try the option wsoNoReceiveLoop, it may help to stop delivering of already
> received data. If you use the option and pause the socket, you will not be
> notified of any data already received and waiting in the buffer. So when you
> resume, you should probably call Receive once to check for remaining data.

> --
> Contribute to the SSL Effort. Visit
> http://www.overbyte.be/eng/ssl.html
> --
> [EMAIL PROTECTED]
> 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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-02-19 Thread Francois PIETTE
> I find that calling pause in OnSessionConnected() is effective.
> But calling pause in OnClientDataAvailable() does not work.
> OnClientDataAvailable() keeps getting fired. Any ideas?

Maybe your socket already received data when you pause it.
Pause only affect winsock notification. It stops notifications from winsock 
but if data is already in, you have to read it.
Try the option wsoNoReceiveLoop, it may help to stop delivering of already 
received data. If you use the option and pause the socket, you will not be 
notified of any data already received and waiting in the buffer. So when you 
resume, you should probably call Receive once to check for remaining data.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-02-19 Thread Arno Garrels
Jack wrote:
> Hello Francois,
> 
> I find that calling pause in OnSessionConnected() is effective.
> But calling pause in OnClientDataAvailable() does not work.
> OnClientDataAvailable() keeps getting fired. Any ideas?

You may have paused the server socket instead of the 
TWSocketClient?

Arno Garrels 
 
> --
> Best regards,
> Jack
> 
> Sunday, January 22, 2006, 10:33:21 AM, you wrote:
> 
 Maybe use Pause/Resume ?
>>> 
>>> Oh, I didn't even know these two methods. So Pause will stop
>>> all network connectivity on that socket until it's resumed?
> 
>> It suppress async notification. So you don't receive events anymore but
>> I/O continue as much as winsock can, for example filling his receive
>> buffer. 
-- 
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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-02-18 Thread Jack
Hello Francois,

I find that calling pause in OnSessionConnected() is effective.
But calling pause in OnClientDataAvailable() does not work.
OnClientDataAvailable() keeps getting fired. Any ideas?

-- 
Best regards,
Jack

Sunday, January 22, 2006, 10:33:21 AM, you wrote:

>>> Maybe use Pause/Resume ?
>>
>> Oh, I didn't even know these two methods. So Pause will stop
>> all network connectivity on that socket until it's resumed?

> It suppress async notification. So you don't receive events anymore but I/O
> continue as much as winsock can, for example filling his receive buffer.



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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-23 Thread Jack
Hello Francois,

> You can't ignore OnDataavailable event !

Got it.

>> > There is a flag FPaused but it is not exposed as a property.

>> Oh, will you be able to expose it? I can modify the source
>> code for now but I think it's useful when Pause and Resume
>> is exposed.

> Not really. You can have a flag set/reset in your own application
> when you call Pause/Resume, or you
> can derive from TWSocket and create the property in your derived
> component. That's what OOP is all about.

Hmm. Is there any particular reason that you don't want to expose
FPaused?

It seems safe to call Resume on all client socket without checking,
am I right?

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Francois Piette
> >>> Maybe use Pause/Resume ?
>
> > It suppress async notification. So you don't receive events anymore but I/O
> > continue as much as winsock can, for example filling his receive buffer.
>
> Got it. Wouldn't this be similar to ignoring OnDataAvailable event

You can't ignore OnDataavailable event ! If you don't call Receive from 
OnDataAvailable event, the
event will be triggered again and again until you read the data. You'll enter 
an infinite loop.
Calling Pause will stop OnDataAvailable from being triggered, this is different.

> and is vulnerable to DOS attack?

Whan paused, a socket will still accept some data, until winsock buffer is 
full. Then transmission
will be stopped until you resume the socket. At that time, you'll start to 
receive data again
(OnDataAvailable will be triggered again). You application has full control 
about what data is sent
and can detect anormal traffic and close the connection.

> > There is a flag FPaused but it is not exposed as a property.
>
> Oh, will you be able to expose it? I can modify the source
> code for now but I think it's useful when Pause and Resume
> is exposed.

Not really. You can have a flag set/reset in your own application when you call 
Pause/Resume, or you
can derive from TWSocket and create the property in your derived component. 
That's what OOP is all
about.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Wilfried Mestdagh
Hello Jack,

>> It suppress async notification. So you don't receive events anymore but I/O
>> continue as much as winsock can, for example filling his receive buffer.

> Got it. Wouldn't this be similar to ignoring OnDataAvailable event
> and is vulnerable to DOS attack?

If you call Pauze then winsock will stay receiving until his buffer is
full. Default value is 8 KB. Later when you wants to receive again and
call Resume all is back to normal. DOS attac will only grow until
winsock buffer is full so not a big deal (8 KB).

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Wilfried Mestdagh
Hello Jack,

> if there is data available but do not want to actually remove
> the data from twsocket's buffer. This is because I want to

You can use Pauze / Resume but there is also a very simple way to do it,
just set wsoNoReceiveLoop in SocketOptions to True and dont Receive in
OnDataAvailable, just Exit.

At that point OnDataAvailable will not fire again.

Later when you wants to receive again, just call Receive outside
OnDataAvailable.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Jack
Hello Francois,

>>> Maybe use Pause/Resume ?

> It suppress async notification. So you don't receive events anymore but I/O
> continue as much as winsock can, for example filling his receive buffer.

Got it. Wouldn't this be similar to ignoring OnDataAvailable event
and is vulnerable to DOS attack?

>> If so, I guess I Pause the client socket and resume it when
>> the resume socket is connected.

> Not sure I understand, but probably the answer is yes :-)

Sorry for the typo. I meant remote, not resume ;) and you
guess is right :)

>> Is there a flat to check if a client socket is paused?

> There is a flag FPaused but it is not exposed as a property.

Oh, will you be able to expose it? I can modify the source
code for now but I think it's useful when Pause and Resume
is exposed.

And sorry for the typo again. I meant flag, not flat. You
got that right, too :)

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Francois PIETTE
>> Maybe use Pause/Resume ?
>
> Oh, I didn't even know these two methods. So Pause will stop
> all network connectivity on that socket until it's resumed?

It suppress async notification. So you don't receive events anymore but I/O 
continue as much as winsock can, for example filling his receive buffer.

> If so, I guess I Pause the client socket and resume it when
> the resume socket is connected.

Not sure I understand, but probably the answer is yes :-)

> Is there a flat to check if a client socket is paused?

There is a flag FPaused but it is not exposed as a property.


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Jack
Hello Francois,

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

> Maybe use Pause/Resume ?

Oh, I didn't even know these two methods. So Pause will stop
all network connectivity on that socket until it's resumed?
If so, I guess I Pause the client socket and resume it when
the resume socket is connected.

Is there a flat to check if a client socket is paused?

> You could receive a lot of data before the other socket is opened. This is a
> potential DOS attack.

This is a good point.

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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Francois PIETTE
> Is there a way to tell the number of bytes available without
> actually retrieving the data?

There is RcvdCount but due to winsock limitation, it is not always accurate.

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

Maybe use Pause/Resume ?

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

You could receive a lot of data before the other socket is opened. This is a 
potential DOS attack.


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Jack
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: 
> 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


Re: [twsocket] OnDataAvailable called before shutdown with no data

2006-01-22 Thread Francois PIETTE
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: 
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