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

Reply via email to