Hello Sham, Yes. You can leave the programming model the same since it is mostly a good technique to make an object for the communication, containing the ftp client. And yes you can make it normal non threaded objects.
As before you create as many as you want to let file transfer simulanously, and they should do their job all in parallel. Each method call that has to do with FTP will generate an OnRequestDone where you can take next action depending on the state of the ftp client. So there you have to check the state, and of course also the Winsock and FTP error if there is one. Be carefull with updating status bar. Component will run in same thread as your display, and GUI updating is very slow. So do the updating of the statusbar not in real time, but every few seconds or so. If you should do it each time some packet is transmitted then you will slow down everything (depending on the connection speed). --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Saturday, April 8, 2006, 12:24, Shamresh Khan wrote: > Hi Wilfried, > This is what we had with indy. > We created a number of threads and in each thread we had a indy ftp client. > Each client puts (ftps) as file and then updates its corresponding progress > bar. Once the thread has finished sending all the data that was allocated to > it (i.e. a number of files), it waits until there are more files allocated. > Since indy is blocking, this worked nicely, each thread waiting for data. > Now, I am trying to change this model to work with asynchronous ICS > components. Are you saying that I should not use the threads and simply > create the ftp clients in normal objects? The onrequestDone will be fired > within the ftp connection thread. Would this allow me to have multiple ftp > clients each sending data and have the progress bars updated simultaneously? > Sham. >>From: Wilfried Mestdagh <[EMAIL PROTECTED]> >>Reply-To: ICS support mailing <twsocket@elists.org> >>To: ICS support mailing <twsocket@elists.org> >>Subject: Re: [twsocket] Cannot change port if not closed >>Date: Sat, 8 Apr 2006 11:43:18 +0200 >> >>Hello Shamresh, >> >> > Do I have to do anything different on the server if I am using ftp >>clients >> > in threads? >> >>Yes. By default TFTPServer will create his clients in the thread context >>where you have created the component, eg the main thread. Normally you >>dont need threads, because the component can handle thousands of clients >>the same time using coorporative multitasking. >> >>But if you have to do a very lengthy operation you block the message >>pump during this operation. So at that moment all communication will >>stop. If it is not too long no problem, winsock will stay on executing >>until his buffers ar full, and when your lengty code finish the >>component will start firing events again. >> >>But if you really need a thread you can do several things. You can >>attach the client to a thread do the lengty thing and detach it again, >>because it has to be attached to the thread where it is created for >>destruction (that's the way windows work). >> >>Another way is to start a thread for the length operation and give the >>thread the socket handle. Later when the thread finish it can do (eg >>send something) with that socket again and meanwile all other code stay >>executing. >> >>But are you sure you want to operate each connection in a separate >>thread ? Normally it is really not needed ! >> >>--- >>Rgds, Wilfried [TeamICS] >>http://www.overbyte.be/eng/overbyte/teamics.html >>http://www.mestdagh.biz >> >>Saturday, April 8, 2006, 11:27, Shamresh Khan wrote: >> >> > I have tested my client with another FTP server and it seems to work. >> >> > So the problem could be with my custom FTP server. >> >> > In my ftp Server I do custom processing in StoreSessionClosedEvent. The >>only >> > other event I have is a Authenticate event. >> >> > Do I have to do anything different on the server if I am using ftp >>clients >> > in threads? >> >> > Sham. >> >> >> >>From: "Shamresh Khan" <[EMAIL PROTECTED]> >> >>Reply-To: ICS support mailing <twsocket@elists.org> >> >>To: twsocket@elists.org >> >>Subject: Re: [twsocket] Cannot change port if not closed >> >>Date: Sat, 08 Apr 2006 09:02:02 +0000 >> >> >> >>Thanks for the information Wilfried. >> >> >> >>One thing I have realised is that my outputDebug messages are not >>showing >> >>(they were showing when I was using indy). >> >> >> >>You said that I should have a working message pump. Not sure what you >>mean >> >>here? >> >> >> >>Thanks. >> >>Sham. >> >> >> >> >> >> >From: Wilfried Mestdagh <[EMAIL PROTECTED]> >> >> >Reply-To: ICS support mailing <twsocket@elists.org> >> >> >To: ICS support mailing <twsocket@elists.org> >> >> >Subject: Re: [twsocket] Cannot change port if not closed >> >> >Date: Sat, 8 Apr 2006 10:38:45 +0200 >> >> > >> >> >Hello Shamresh, >> >> > >> >> > > In my client I have set multithreaded to true (but not on the >>server). >> >> > >> >> >No. Multithreaded is if you create the component in a thread other >>than >> >> >the main thread. However I'm not sure this is related to your problem. >> >> > >> >> > > I have just moved over from indy, so non blocking events are giving >>me >> >>a >> >> >bit >> >> > > of a headache. >> >> > >> >> >You will get used to it very fast. After all, windows / delphi works >> >> >also event driven. Some hints could be (maybe related to your >>problem): >> >> > >> >> >- dont call the message pump from withing an event. This include also >>a >> >> > modal form (like ShowMessage), or (bad written) components that >>call >> >> > it internally. If you call the message pump then the event can get >> >> > re-entered at that moment. >> >> >- write a state machine. Some event fire and depending on the state >>you >> >> > can take the right action. >> >> >- always have a working message pump. If you block the message pump >>the >> >> > component will stop working until it pumps again. >> >> >- dont write wait loops. it is considered as bad programming >>technique. >> >> > You also dont write a wait loop waiting until a button is clicked >>:) >> >> > >> >> >--- >> >> >Rgds, Wilfried [TeamICS] >> >> >http://www.overbyte.be/eng/overbyte/teamics.html >> >> >http://www.mestdagh.biz >> >> > >> >> >Saturday, April 8, 2006, 10:11, Shamresh Khan wrote: >> >> > >> >> > > Hi to all, >> >> > >> >> > > I have just moved over from indy, so non blocking events are giving >>me >> >>a >> >> >bit >> >> > > of a headache. >> >> > >> >> > > I have a number of files that are uploaded to my custom server. >> >> > >> >> > > I get an exception raided "Cannot change port if not closed" after >> >> >several >> >> > > files have been uploaded. >> >> > >> >> > > In my client I have set multithreaded to true (but not on the >>server). >> >> > >> >> > > My server is listening on port 21 and I am not clear why a port >>change >> >> > > exception is raised. The stack dump on the server is : >> >> > >> >> > > TCustomWSocket.RaiseException('Cannot change Port if not closed') >> >> > > TCustomWSocket.SetRemotePort('1849') >> >> > > TFtpServer.CommandSTOR($E527EC,???,'testFile23.dat-FS=12','') >> >> > > TFtpServer.ClientCommand(???,???,???) >> >> > > TFtpCtrlSocket.TriggerCommand(???,???) >> >> > > TFtpCtrlSocket.TriggerDataAvailable(???) >> >> > > TCustomWSocket.ASyncReceive(0,[]) >> >> > > TCustomWSocket.Do_FD_READ(???) >> >> > > TCustomWSocket.WMASyncSelect((1025, 1456, 1, 66179, 1456, 0, 1, 0, >> >>643, >> >> >1)) >> >> > > TCustomWSocket.WndProc((1025, 1456, 1, 66179, 1456, 0, 1, 0, 643, >>1)) >> >> > > XSocketWindowProc(???,???,1456,1) >> >> > >> >> > > Any help would be appreciated. >> >> > >> >> > > Sham. >> >> > >> >> > >> >> > >> >> >-- >> >> >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 -- 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