Re: [twsocket] ICS Client Thread Safe

2008-05-13 Thread Wilfried Mestdagh
Hello Éric,

Can you start a new message instead of a reply if you start a new
subject please? Many people will not see your message now.

 I would like to know if the Send routine of TCustomWSocket is thread safe.

Yes in the later versions it is protected by a critical section. It can
be switched on / off by a $define.

 Can I have for example one client class connected to my server and have a
 some threads sending data to the server over this connection?

Yes but please check the CriticalSection in the source first and
remember to have the conditional compilation for that project.

---
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://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] OnDataSent event and related questions

2008-05-13 Thread info2004
Hi,

I am currently using the OnDataSent event of TWSocket to signal my state 
machine 
to move on. This is working mostly, however, sometimes, the event does not 
happen.

Now, at the far side, the server being connected to closes the connection when 
it has it's data, so I am thinking that this close will sometimes mask the 
OnDataSent. It is happening about 1 packet in 40, each packet being 60 bytes.

Some of the servers will not close the connection after a packet, and some do, 
some servers send a acknowledge packet back, so I need a reliable method of 
testing that the data has gone, before I can proceed in the state machine.

Is hooking the disconnect event a valid approach if the OnDataSent event does 
not fire?

Regards,

Andy
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OnDataSent event and related questions

2008-05-13 Thread Arno Garrels
info2004 wrote:
 Hi,
 
 I am currently using the OnDataSent event of TWSocket to signal my
 state machine to move on. This is working mostly, however, sometimes,
 the event does not happen. 
 
 Now, at the far side, the server being connected to closes the
 connection when 
 it has it's data, so I am thinking that this close will sometimes
 mask the OnDataSent. 

When the server closes the connection OnSessionClosed triggers. 
In order to check whether component's internal send buffer is empty
you have property BufferedByteCount.

If your application has to close the connection when all data
has been sent, you should use method ShutDown(1) from the OnDataSent
event, this makes sure the receiver will receive everything.


--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html




-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OnDataSent event and related questions

2008-05-13 Thread info2004
Arno,
Arno Garrels wrote:
 info2004 wrote:
 When the server closes the connection OnSessionClosed triggers. 
 In order to check whether component's internal send buffer is empty
 you have property BufferedByteCount.
 
 If your application has to close the connection when all data
 has been sent, you should use method ShutDown(1) from the OnDataSent
 event, this makes sure the receiver will receive everything.

I think that we are at cross purposes here. The OnDataSent event looks like it 
does not fire (sometimes) if the far end (server) closes the connection. Is 
this 
true?

The server gets the data, then closes the connection, and at my sending end if 
I 
solely wait for OnDataSent, sometimes it does not happen, and I time out.

I just really want to make sure my assumption is correct before I can put this 
to bed.

Regards,

Andy
 
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OnDataSent event and related questions

2008-05-13 Thread Wilfried Mestdagh
Hello Andy,

 I think that we are at cross purposes here. The OnDataSent event looks like it
 does not fire (sometimes) if the far end (server) closes the connection. Is 
 this
 true?

OnDataSent is fired when TWSocket has delivered his data to winsock. As
Arno pointed out it is not a signal that the data is arrived at the
other end.

If the other end close the connection before TWSocket has delivered the
data to Winsock then OnDataSent will of course not fire.

 The server gets the data, then closes the connection, and at my sending end 
 if I
 solely wait for OnDataSent, sometimes it does not happen, and I time out.

So the peer that receive the data will close? That's good, so you are
sure it is delivered before the connection closes. You may consider to
design a small protocol so that both end talk to each other and know all
data is sent / delivered / handled with success.

 I just really want to make sure my assumption is correct before I can put this
 to bed.

now you can :)

---
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://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] TWSocket.Send timing

2008-05-13 Thread info2004
Hi,

I am logging the time before and after a call to Send. I am sending 60 bytes, 
and the Send call is taking 300ms to complete.

Does this sound right?

I am running a P4 2.4GHz 1G ram. I was expecting 10's of ms really.

If this is to be expected, then I won't ask the next question - which would be 
how to speed it up.

Regards,

Andy
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Send timing

2008-05-13 Thread Wilfried Mestdagh
Hello Andy,

 I am logging the time before and after a call to Send. I am sending 60 bytes,
 and the Send call is taking 300ms to complete.

this is the nagle algoritm. nagle wait a little while to see if you want
to send more. this is to fill up a complete packet of 1514 (?) bytes.
You can speed it up by setting wsoTcpNoDelay in ComponentOptions in both
ends, but this can slow down network performance. See MSDN at Microsoft
are many articles discussing it.

---
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://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Send timing

2008-05-13 Thread info2004
Wilfried,

I'll have a look on MSDN and see what they say.

I think that I will try and pad out my data to the min packet size an dsee if 
that speeds things up, or screws up the server.

Regards,

Andy
Wilfried Mestdagh wrote:
 Hello Andy,
 
 I am logging the time before and after a call to Send. I am sending 60 bytes,
 and the Send call is taking 300ms to complete.
 
 this is the nagle algoritm. nagle wait a little while to see if you want
 to send more. this is to fill up a complete packet of 1514 (?) bytes.
 You can speed it up by setting wsoTcpNoDelay in ComponentOptions in both
 ends, but this can slow down network performance. See MSDN at Microsoft
 are many articles discussing it.
 
 ---
 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://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] TWSocket.Send timing

2008-05-13 Thread Dan F
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Wilfried Mestdagh
 Sent: 13 May 2008 19:34
 To: ICS support mailing
 Subject: Re: [twsocket] TWSocket.Send timing
 
 Hello Andy,
 
  I am logging the time before and after a call to Send. I am sending
 60 bytes,
  and the Send call is taking 300ms to complete.
 
 this is the nagle algoritm. nagle wait a little while to see if you
 want
 to send more. this is to fill up a complete packet of 1514 (?) bytes.
 You can speed it up by setting wsoTcpNoDelay in ComponentOptions in
 both
 ends, but this can slow down network performance. See MSDN at Microsoft
 are many articles discussing it.
 
 ---
 Rgds, Wilfried [TeamICS]

I thought the Nagle algorithm would only apply to the speed at which the
underlying Winsock socket sends the data.  As far as I know it shouldn't
cause the TWSocket send call to take longer since that is asynchronous isn't
it?  Please correct me if I'm wrong.

Dan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be