[twsocket] Little question... TList of HTTPCli

2005-05-03 Thread Ann
Hello ;-) It's me again...
Just one little question...
When i have a TList of busy HTTPCli'ents how do i know which one should i
remove on OnRequestDone event?

Thank you,
Ann



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

2005-05-03 Thread Francois Piette
 There are two other components in the dll which 
 suffer from the very same
 problem. One is the timer and another is one for the 
 other communication method which
 doesn't have a processmessages. 

Obviously, you failed to have a working message pump.

 Do you have any hints for these as well?

Study the IcsDll1 sample program !

--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: [EMAIL PROTECTED]
To: TWSocket@elists.org
Sent: Tuesday, May 03, 2005 10:22 AM
Subject: [twsocket] ProcessMessages


 Hello,
 
 I think I must describe my problem a bit more detailed than before.
 I'm building a dll to encapsulate my communication routines to some extend.
 The dll manages all connections. When a new udp connection is to be made,
 a handle of my own type is allocated (I have other communication types 
 implemented in the same dll) and the adress of a callback procedure
 is given. With this handle data can be sent out.
 
 The dll contains a data odlue with one TWSocket for receiving udp data.
 his is configured on a fixed ip/port on the local pc and if data is
 received,
 it looks in the handle list which callback is to be called (depending on the
 
 ip of the sender). The data is passed to this callback then.
 
 My test for this is an application which continously requests data from a 
 hardware device and checks if the packets received are correct.
 
 This app. is a vcl one. If it has application.processmessages in its loop,
 all works as expected. But: my dll will later not be used by a vcl
 application but
 by a bunch of other dlls, so application.processmessages is not feasible.
 I discovered now that twsocket also has processmessages. I tried to set up a
 single
 thread in the dll which continously calls processmessages on that fixed
 socket
 (the receiving one, the sending sockets are created dynamically when a new
 connection 
 gets added and get destroyed when the connection is closed [normally at the
 end of the
 program in my case]). t doesn't work. The thread is called, but data isn't
 received.
 
 There are two other components in the dll which suffer from the very same
 problem.
 One is the timer and another is one for the other communication method which
 doesn't 
 have a processmessages. Do you have any hints for these as well?
 
 I'm stuck richt now...
 
 Greetings
 
 Markus Humm
 -- 
 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


[twsocket] Messages

2005-05-03 Thread Markus . Humm
Hello,

does a sending TWSocket need to have its messages processed? If yes how is
this done? 
A simple loop directly after sending which calls processmessages of the
socket?

Greetings

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


AW: [twsocket] ProcessMessages

2005-05-03 Thread Markus . Humm
  There are two other components in the dll which 
  suffer from the very same
  problem. One is the timer and another is one for the 
  other communication method which
  doesn't have a processmessages. 
 
 Obviously, you failed to have a working message pump.
 
  Do you have any hints for these as well?
 
 Study the IcsDll1 sample program !
 

Okay, did I understood it right:

- the receiving TWSocket can't be a static component on the datamodule
because
  it has to be in a thread?

- the sending TWSocket doen't need to be created in an thread because that
sends
  at once (nearly) without the need of windows messages

Greetings

Markus
-- 
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] Messages

2005-05-03 Thread Wilfried Mestdagh
Hello Markus,

You can use the messagepump of one of the TWSocket you creeate. Be sure
to set MultiThreaded to True; You have to create all components IN
Execute method of the thrad, assigne all events, and then just call the
messagepump of 1 of the components. Dont forget to destroy all
components also in Execute method before it ends.

---
Rgds, Wilfried
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] Messages

2005-05-03 Thread Francois Piette
 does a sending TWSocket need to have its messages processed?

Yes, it have to.

 If yes how is this done?
 A simple loop directly after sending which calls
 processmessages of the socket?

Anything that makes messages properly processed is good. But be aware of the 
context where it is
called. You can't call the message pump from anywhere.

--
[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] ProcessMessages

2005-05-03 Thread Francois Piette
 - the receiving TWSocket can't be a static
 component on the datamodule
 because it has to be in a thread?

Yes, the component has to be _created_ within the context of the thread that 
will handle his events.
In case of TWSocket, you have ThreadDetach and ThreadAttach methods if it is 
not possible to create
the component within the thread execute. But those method have a drawback; 
between the two, the
component will not handle his events ! So it is much better to create the 
component directly in the
correct thread context.

 - the sending TWSocket doen't need to be created in an thread because that
 sends at once (nearly) without the need of windows messages

Wrong. Sending and receiving btoh use messages, even if in some cases it seems 
to be direct.

--
[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] Little question... TList of HTTPCli

2005-05-03 Thread Bjørnar Nielsen
In C++ I would do something like this:

int index=list-Remove(Sender);

If Sender (your httpcli) is in that list, it will be removed, and it will
return the index of the position before it is removed if the Sender was in
the list.

You should see the helpfiles, many examples and usefull hints there..

Regards Bjørnar

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ann
Sent: 3. mai 2005 13:53
To: ICS support mailing
Subject: Re: [twsocket] Little question... TList of HTTPCli

yes but im not asking about sender but how do i find this sender in tlist of
components...

do i have to make something like this or is there easier way?

for i:=0 to list.item.count-1 do
 begin
  if list.item[i] = sender then this_is_the_one?
 break;
 end;

- Original Message -
From: Francois Piette [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Tuesday, May 03, 2005 11:26 AM
Subject: Re: [twsocket] Little question... TList of HTTPCli


  Just one little question...
  When i have a TList of busy HTTPCli'ents how do i
  know which one should i
  remove on OnRequestDone event?

 You have the sender argument in OnRequestDone. It's the Http component
that sent the event. You can
 cast it to THttpCli and do whatever you like.

 btw: This is basic Delphi programming. The sender argument of any event
always refers to the
 component source of the event. You always need it when the same handler is
used for many components.

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





-- 
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: AW: [twsocket] Messages

2005-05-03 Thread Wilfried Mestdagh
Hello Markus,

If you call the message pump, then depending on who called your code,
your function can be re-entered. For example if the caller himself comes
from the messagepump then it can be calling again if message in queue.

Most of the time pumping messages in code is a bad idea and should not
be done (this sayed I just did it in a program of mine for the first
time in my life with a big 'Todo:' in it :)

---
Rgds, Wilfried
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


[twsocket] FTPCli. Problem with QUIT

2005-05-03 Thread Kim Mølgård Nielsen
Hello All

I have an application that use FTPCLI to fetch some files from a server. Async 
is used. It runs on a number of PC's. On a single PC running XP I sometimes 
have trouble quiting from a FTP server (WEB6 Microsoft FTP Service (Version 
5)). The ICS version used was downloaded the 9/3-05 - I'm currently trying to 
get the error with the latest version.

Here is how it looks in the log when the QUIT command is send.

  QUIT
 Disconnected,10053FTPSessionClosed
 RequestDone: 15, 500, 43, 33, 22, 0 FTPRequestDone

Disconnect returns an 10053 winsock error and RequestDone returns FTP error 500.

Is this a known problem?
Could the problem be timing when the control socket is closed?



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

2005-05-03 Thread Francois Piette
  You can't call the message pump from anywhere.

 Where would it be impossible?

Each time you call the message pump, you trigger message processing. If you 
trigger message
processing, you must be prepared to have your event reentered. Basically it is 
not a problem but
actually it is since most event handler are not reentrant.

--
[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] Messages

2005-05-03 Thread Francois PIETTE
 udp.addr   :=ip;

What IP address do you use ? It must be either '0.0.0.0' or the IP address
of the network interface you want to listen to.

--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: [EMAIL PROTECTED]
To: twsocket@elists.org
Sent: Tuesday, May 03, 2005 5:14 PM
Subject: [twsocket] Messages


 Hello,

 after sendin I have now (only for test purposes) a 100 ms loop
 which calls twsocket's processmessages. The result is, that sending
 now works fine again from the test app. and the test app. responds
 to mouse clicks etc. again.

 For the receiving part I did this (the contents of tthread execute):

   try
 udp:=TWSocket.Create(nil);
 udp.addr   :=ip;
 udp.Port   :=port;
 udp.Proto  :='udp';
 udp.SendFlags  :=wsSendNormal;
 udp.MultiThreaded  :=true;
 udp.OnDataAvailable:=dm.udpDataAvailable;

 udp.Listen;

 udp.MessageLoop;
   except
 exit;
   end;

 with dm.udpdataavailable the former dataavailable from the socket which
 was placed statically on a datamodule and did formerly the receiving part.

 The thread is started, but  can't receive anything. OnDataAvailable
doesn't
 fire although there is data available.

 What's wrong with it? It seems I'm near the solution, but haven't got it
 yet.

 Greetings

 Markus Humm
 -- 
 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[2]: [twsocket] Messages

2005-05-03 Thread Wilfried Mestdagh
Hello Bjørnar,

 Is the code really running in thread-context?

Good point. He has to check (but I alrady think I mentioned this) that
MultiThreaded is set to True.

Try GetCurrentThreadId to check current thread context.

---
Rgds, Wilfried
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] Messages

2005-05-03 Thread Wilfried Mestdagh
Hello Markus,

 For the receiving part I did this (the contents of tthread execute):
 udp.MessageLoop;

Are you very sure this is exacly what you want ?  MessageLoop will
pump messages, but will actually stay there until a WM_QUIT is received.
If you dont watch carefully you will end up with a lots of loops pumping
messages and consuming CPU in your application.

In my opinion you are making it very difficult trying to sequentional
programming with event driven components.

In fact you onle need in Execute method of thread:

// create all of your components
// assigne all event handlers
Sock.MessageLoop;
// destroy them all

that's all you have to do !
all the rest is the same as in normal programming with the exception
that you have to do thread safe code of course !

---
Rgds, Wilfried
http://www.mestdagh.biz

Tuesday, May 3, 2005, 17:14, [EMAIL PROTECTED] wrote:

 Hello,

 after sendin I have now (only for test purposes) a 100 ms loop
 which calls twsocket's processmessages. The result is, that sending
 now works fine again from the test app. and the test app. responds 
 to mouse clicks etc. again.

 For the receiving part I did this (the contents of tthread execute):

   try
 udp:=TWSocket.Create(nil);
 udp.addr   :=ip;
 udp.Port   :=port;
 udp.Proto  :='udp';
 udp.SendFlags  :=wsSendNormal;
 udp.MultiThreaded  :=true;
 udp.OnDataAvailable:=dm.udpDataAvailable;

 udp.Listen;

 udp.MessageLoop;
   except
 exit;
   end;

 with dm.udpdataavailable the former dataavailable from the socket which
 was placed statically on a datamodule and did formerly the receiving part.

 The thread is started, but  can't receive anything. OnDataAvailable doesn't
 fire although there is data available.

 What's wrong with it? It seems I'm near the solution, but haven't got it
 yet.

 Greetings

 Markus Humm


-- 
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: Re[2]: [twsocket] Little question... TList of HTTPCli

2005-05-03 Thread Ann

- Original Message - 
From: Wilfried Mestdagh [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Tuesday, May 03, 2005 2:08 PM
Subject: Re[2]: [twsocket] Little question... TList of HTTPCli


 Hello Ann,
 
 Yes. What you also can do is:
   i := List.IndexOf(Sender);
 Then i is the index in the List where Sender is, or -1 if not found
 and you can thus use it to add the right item to another list and/or
 remove it etc...
 

Thank you guys! I love ya! :-)
Ann


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