Hello Sham,

> One thing I have realised is that my outputDebug messages are not showing
> (they were showing when I was using indy).

The main difference is that your code is now operating in the thread
context where you have created the component. How do you show the debug
messages ?

> You said that I should have a working message pump. Not sure what you mean

Each (hidden) window in windows has to have a working message pump.
Delphi is hiding that for you. For example you create a form, and Delphi
take care of it. It will pump until you for example click a button. Then
your code will execute and as long as your code block run you block the
pump. When you exit the buttonClick then Delphi enters the message pump
again.

>From your code you can pump also by calling Application.Processmessages.
In most (if not all) case this is never needed. It can also be very bad
because you enter the pump yourself, so a pending message (eg an event
or a mouse click or whatever) will execute. Doing this it is possible
you re-enter your own code block while it is executing.

So normally you dont have to worry about because you normally have a
working message pump, also if you create a window yourself with
AllocHWND witch have a WndProc argument witch is called by the message
pump that Delphi create for you.

It is different if you do something in a thread. If you create a
component in a thread then TWSocket will create his hidden window.
Fortunally TWSocket has his own (thread safe) message pump on board, so
you have to set multithread True and call it yourself. You can also easy
create a message pump with GetMessage api function.

I hope this infomration make sence.

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

Saturday, April 8, 2006, 11:02, Shamresh Khan wrote:

> 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

Reply via email to