Re: [twsocket] Question about twsocketthrdserver
Tony Caduto wrote: Hi, I have a chat server is ported from synapse and I used twsocketthrdserver so it would scale with 200 sockets per thread. The problem is in my original server i used a generic tdictionary to store pointers to the client objects. I use a critical section to protect the tdictionary and this all works great except when I go over 200 connections, then when a user sends a message to a user in the 2nd thread one of them dies, the 2nd thread does not terminate but it's like the message pump dies. I use the protected tdictionary to locate the recipient socket object. The thread list and the client list are private and I can't make use of them in the stock component. Anyone have any ideas on what may be going on? Access to the protected TDictonary object is thread-safe, however it is not calling methods and access properties of the client objects. You have to communicate with the clients using Window messages. Look at how TWSocketThrdClient defines a new message ID and overrides its WndProc method. BTW: I just checked in some fixes of OverbyteIcsWSocketTS.pas some 64-bit and one message pump fix. -- Arno -- 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] Question about twsocketthrdserver
Arno Garrels wrote: Access to the protected TDictonary object is thread-safe, however it is not calling methods and access properties of the client objects. You have to communicate with the clients using Window messages. Look at how TWSocketThrdClient defines a new message ID and overrides its WndProc method. And even that won't be safe. If, for instance, the client has been detached from its thread, that is its Handle property is zero, and you call PostMessage(Client.Handle..) the handle will be recreated in the context of the calling thread, which will likely cause an error when the component finally destroys the Handle in main thread context. Bottomline: Do not use this class if you ever need to access client objects from outside their own event handlers. Instead TWSocketServer should be used, do lengthy, blocking tasks in a worker thread. -- Arno -- 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] Question about twsocketthrdserver
I'm just doing a sendline after finding the client object in the tdictionary, doesn't a send just put the data in the buffer? I even put the sendline in the critical section and one of the clients still stops responding after about 10 to 20 messages are sent, so it does work for awhile. I will check out the latest code from svn and see what happens. On Apr 9, 2012 6:22 AM, Arno Garrels arno.garr...@gmx.de wrote: Arno Garrels wrote: Access to the protected TDictonary object is thread-safe, however it is not calling methods and access properties of the client objects. You have to communicate with the clients using Window messages. Look at how TWSocketThrdClient defines a new message ID and overrides its WndProc method. And even that won't be safe. If, for instance, the client has been detached from its thread, that is its Handle property is zero, and you call PostMessage(Client.Handle..) the handle will be recreated in the context of the calling thread, which will likely cause an error when the component finally destroys the Handle in main thread context. Bottomline: Do not use this class if you ever need to access client objects from outside their own event handlers. Instead TWSocketServer should be used, do lengthy, blocking tasks in a worker thread. -- Arno -- 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 -- 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] Question.
On Jan 7, 2008, at 13:55, Andre Paradis wrote: For now, I have modify the HttpProt.pas but we keep our ICS package up to date since many years now, and this modification in this unit will make our life a little bit more complicated. The easiest way is to extend HttpCli by descending from the class and overriding the appropriate methods, instead of changing the code on the HttpProt unit itself. dZ. -- DZ-Jay [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] Question.
So you confirm, I don't have any other way to support a new key in the Http Header. Andre. Andre Paradis Logiciel LOC Software [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of DZ-Jay Sent: January-07-08 2:11 PM To: ICS support mailing Subject: Re: [twsocket] Question. On Jan 7, 2008, at 13:55, Andre Paradis wrote: For now, I have modify the HttpProt.pas but we keep our ICS package up to date since many years now, and this modification in this unit will make our life a little bit more complicated. The easiest way is to extend HttpCli by descending from the class and overriding the appropriate methods, instead of changing the code on the HttpProt unit itself. dZ. -- DZ-Jay [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 -- 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] Question.
On Jan 7, 2008, at 14:45, Andre Paradis wrote: So you confirm, I don't have any other way to support a new key in the Http Header. I'm not sure what it is that you are after... dZ. -- 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] Question.
Hi, I have a question regarding WebService and HTTP Header. Instead of using MSSOAP, I create manually the HTTP request for Soap service. On some server, I need to set SoapAction in the Http Header, how do you suggest supporting that? Thank you. -- 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] Question.
On Jan 7, 2008, at 15:49, Andre Paradis wrote: Hi, I have a question regarding WebService and HTTP Header. Instead of using MSSOAP, I create manually the HTTP request for Soap service. On some server, I need to set SoapAction in the Http Header, how do you suggest supporting that? You could handle the OnRequestHeaderStart or OnRequestEnd events and inject the additional headers you need. These events will be triggered right before or after the response headers are sent, respectively. dZ. -- DZ-Jay [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] Question about changing some UDP application
- for each device the PC has one UDP socket for the sending side. That is not necessary. You can send using the [single] listening socket. Use SendTo instead of Send method. - I'd like to get rid of my fixed IP address. As far as your Delphi program is concerned, this has no impact. It only impact your devices which must understand a hostname and do the appropriate name resolution. Ask your device provider. Would it be possible on the PC side to simply have each UDP socket listen and a OnDataAvailable event handler on each of those sockets? Would that be sufficient on the PC side? You need one TWSocket instance per port you want to listen to. You can use that socket to send UDP datagram to the device. If all your devices ause the same port, then only a single socket is needed. You must use ReceiveFrom to know which device sent the datagram and SendTo to send the reply/command to the correct device. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be - Original Message - From: Markus Humm [EMAIL PROTECTED] To: twsocket@elists.org Sent: Thursday, December 27, 2007 10:26 AM Subject: Re: [twsocket] Question about changing some UDP application Hello, I fear you all haven't yet completely understood my problem, so here I go again: - my application uses UDP and must use it - there is one PC - there are up to several (can also be only be one device but that doesn't matter) hardware devices where I've no control over the firmware except what it's configuration settings allow me - as it is now, the PC has a fixed IP address and sends requests to those devices. The devices will process these requests and send the answer back to that fixesd IP and a fixed port. This is set in their configuration and each uses the same port/IP - on the PC side there is one single socket for the receiving part which is set on that fixed IP of the PC and this port the devices are sending their answers to - for each device the PC has one UDP socket for the sending side. I want to change this as follows with the least possible impact: - I'd like to get rid of my fixed IP address. - For this I need to check first if whether the configuration of my hardware devices can be changed so they answer back to the IP the request came from and the right port number Would it be possible on the PC side to simply have each UDP socket listen and a OnDataAvailable event handler on each of those sockets? Would that be sufficient on the PC side? Greetings Markus -- 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 -- 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] Question about changing some UDP application
Hello, I fear you all haven't yet completely understood my problem, so here I go again: - my application uses UDP and must use it - there is one PC - there are up to several (can also be only be one device but that doesn't matter) hardware devices where I've no control over the firmware except what it's configuration settings allow me - as it is now, the PC has a fixed IP address and sends requests to those devices. The devices will process these requests and send the answer back to that fixesd IP and a fixed port. This is set in their configuration and each uses the same port/IP - on the PC side there is one single socket for the receiving part which is set on that fixed IP of the PC and this port the devices are sending their answers to - for each device the PC has one UDP socket for the sending side. I want to change this as follows with the least possible impact: - I'd like to get rid of my fixed IP address. - For this I need to check first if whether the configuration of my hardware devices can be changed so they answer back to the IP the request came from and the right port number Would it be possible on the PC side to simply have each UDP socket listen and a OnDataAvailable event handler on each of those sockets? Would that be sufficient on the PC side? Greetings Markus -- 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] Question about changing some UDP application
On Dec 23, 2007, at 07:31, Francois PIETTE wrote: Fixed IP has no relation with the number of sockets. It's just a matter of DNS. I think I understand what he means: He currently has a single server/client and both of them are hard-coded to connect to each other via their IP addresses. He needs to build his system so that all the (multiple) clients on the network can connect to the server and that the server does not respond to original test client IP it has hard-coded only. Is this correct, Markus? If so, its very simple and you probably do not need to do anything extra: All clients need to know the IP address of the server (or to where ever they are connecting), and once they connect to it, the server socket will be bound and all responses will go to it. In TWSocket, the difference between the client and server socket is that the client initiates the connection and the server listens on the port waiting for it. But once the connection is established, they both communicate in exactly the same way and there is virtually (or perhaps even technically) no distinction. If you need to handle multiple clients at a time, you should consider using TWSocketServer, which does this beautifully and very simply (check out TcpSrv demo in the ICS distribution). After a client is connected, the listening socket spawns a new listener-client object to handle it, and from there on, they can communicate. If this does not address your issue, then could you please rephrase your problem with more precise details, as we are not understanding it properly. Thanks, dZ. -- DZ-Jay [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] Question regarding ActiveDirectory in FTP for Arno
Arno, I think you misunderstood. For each folder listing record (file or folder in Windows, plus links in UNIX) in FTP, the FTP server GETs the permissions from the system for display purposes. This is not for CHMOD setting, this is for folder listings. Please tell me how will I get the read/write/execute permissions from the AD for each folder without attempting each operation. There must be a practical way! Regards, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Friday, August 31, 2007 5:56 PM Subject: Re: [twsocket] Question regarding ActiveDirectory in FTP for Arno Fastream Technologies wrote: Helo Arno, I wonder how would one determine the permission field for FTP directory listings. For example: drwxrwxrwx This may not be needed for the demo yet definitely required for a real server. SurgeFTP does this but it's not open source. FileZilla has no AD support. I doubt that SurgeFTP realy writes permissions on a Windows box. Setting NTFS rights is no problem _if_ somebody knows how to translate the UNIX access mask into a Windows mask? -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- 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: [twsocket] Question regarding ActiveDirectory in FTP for Arno
Fastream Technologies wrote: BTW, I see that this demo cannot get permissions for folders (only files). Is there a special reason for this? It works with directories as well, of course. And with a few changes with all Securable Objects. I uploaded the source code here: http://www.duodata.de/misc/delphi/ChkAcc.zip But hav not checked BCB compatibility, though I think it should work with BCB as well. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, September 01, 2007 1:32 PM Subject: Re: [twsocket] Question regarding ActiveDirectory in FTP for Arno Arno Garrels wrote: I use these Windows API functions: GetNamedSecurityInfo() MapGenericMask() AccessCheck() Anyway, I don't know how to translate the resulting mask to unix format, also there's no reliable way to get the effective rights of users without having the user access token, even XP shows sometimes nonsense effektive rights of not logged on users. Btw: If you want to see the above functions in action get this small demo binary from here : http://www.duodata.de/misc/delphi/ChkAcc.zip And then tell us your idea how to form the UNIX mask from it, that includes three parts for Owner, Group and Public. Arno Garrels -- 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: [twsocket] Question regarding ActiveDirectory in FTP for Arno
Fastream Technologies wrote: Helo Arno, I wonder how would one determine the permission field for FTP directory listings. For example: drwxrwxrwx This may not be needed for the demo yet definitely required for a real server. SurgeFTP does this but it's not open source. FileZilla has no AD support. I doubt that SurgeFTP realy writes permissions on a Windows box. Setting NTFS rights is no problem _if_ somebody knows how to translate the UNIX access mask into a Windows mask? -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- 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] Question regarding Delphi 2007
D2007 uses 36MB (working set) at startup, with ICS-V6 project group loaded. When rebuilding all projects, it grows to 81MB. Speaking virtual memory space, the numbers are 210MB/235MB. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Hoby Smith [EMAIL PROTECTED] To: twsocket@elists.org Sent: Tuesday, March 20, 2007 3:48 AM Subject: [twsocket] Question regarding Delphi 2007 Hello all. This might be a bit Off Topic. However, since Francois mentioned D2007, I hope you don't mind if I ask a more specific question regarding D2007. You mentioned that it is fast and reliable product. I was wondering if it is any better regarding resource usage than D2006? Specifically, regarding loading multiple instances / apps at a time for debugging dependant applications? Often, it is necessary for me to debug more than one Delphi app at a time, sometimes even 3 or more (server, client, broker, admin tools, etc). With older Delphis (D6, etc) this was NEVER a problem. But, D2006 is SO HORRIBLE regarding resource utilization, that I can't load more than 2 apps. On trying to load a third instance of D2006, it fails with numerous errors and just dies loading Delphi. Ugggh! And, annoyingly, I have a pretty beasty machine, more than I ever had with Delphi before for sure. I LOVE Delphi AND BORLAND, but D2006 is the most dissappointing and worst quality product that I have ever got from Borland. While it had some great new productivity features, it is full of so many bugs, including MAJOR memory leaks, that have yet to be fixed and that are so bad I sometimes have to reload Delphi 2006 several times a day or my machine comes to a grinding halt. If I am so bold as to try and load TWO instances of D2006, the problems appear to be more frequent. I am really shocked. I have never seen Borland put out a product this bad before, at least as regards quality. And QC is full of issues like that, but with no response or anticipated fix date. It has made me leery to try another product from them for a while. So, have you found that it can actually load more than 2 apps / instances at a time without dying? I would appreciate any feedback on this, because if it is better in this regard, it will be much easier for me to justify my company spending more money on yet another Delphi IDE. :) Thanks much... Hoby -- 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: [twsocket] [QUESTION] THttpCli and SocketError
Hello Guillaume, of course change the WSocketServer I used (I just did a copy/paste from one of my code). GM Hi all, GM is there a way when, on ThttpCli.OnSocketError is triggered, to know what was the error ? GM i mean is it an error from TCP/IP stack, a system error (like no handle, etc...) GM Thanks, GM Regards, GM -- GM Guillaume MAISON - [EMAIL PROTECTED] GM 83, Cours Victor Hugo GM 47000 AGEN GM Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 GM e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] THttpCli and SocketError
Dod a écrit : Hello Guillaume, of course change the WSocketServer I used (I just did a copy/paste from one of my code). Thanks ! i'll check it when i test my application :) regards, -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] ThttpServer and threading design
I have a similar design, but I also have a pointer to the thread in the THttpConnection so that the connection can set a flag on the thread if the connection is dropped before the thread has finished the work and risk using a freed connection. This design could serve several connections/threads at the same time. Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Guillaume MAISON Sent: 9. februar 2006 10:59 To: ICS support mailing Subject: [twsocket] [QUESTION] ThttpServer and threading design Hi everyone, i've an application to write, a client and a server. i've choosen to use the HTTP protocol to enable communication through them. Hence, i'll use the THttpServer as my server front-end. my question is the following : some requests may use some database stuff (SQLite). It shouldn't be the case, but, in case the SQL stuff may need long duration (long10 secs) i prefer to use threads to get DB data, as there may be several clients connecting at the same time. Am i right to implement such requests as this : Form.OnGetDocument : Create a Thread with the HttpConnection attached and FreeOnTerminate:=True; Assign a OnThreadTerminate Run the thread Set Flags to hgWillSendMySelf Form.OnThreadTerminate AttachedHttpConnection.AnswerString/AnswerStream/AnswerWhatever Does this design seem good ? i mean will i be able to serve several connections at the same time (independantly of DB concurrential access that i'll manage within thread context) ? Thanks in advance for your help ! Regards, -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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: [twsocket] [QUESTION] ThttpServer and threading design
Bjørnar Nielsen a écrit : I have a similar design, but I also have a pointer to the thread in the THttpConnection so that the connection can set a flag on the thread if the connection is dropped before the thread has finished the work and risk using a freed connection. True ! i haven't seen it ! This design could serve several connections/threads at the same time. Thanks a lot ! -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] ThttpServer and threading design
Hello Guillaume, Until know what I use to do is to create a worker thread and send jobs (with pointer to socket client object) and then worker send back a message to socket thread with pointer of data to send back to client. So all socket things is done from same thread. Dettaching clientsocket from socket thread to attach it into worker thread when starting lenghty operation is something I never did. I have one question regarding this... if some socket event come during the lengthly operation (OnDisconnect or OnDataAvailable for example), will they be triggered during operation or only at end of it ? If socket is MultiThread:=true it should use its own message queue so react instantly whenever the thread it is attached into is busy isn't it ? GM Bjørnar Nielsen a écrit : I have a similar design, but I also have a pointer to the thread in the THttpConnection so that the connection can set a flag on the thread if the connection is dropped before the thread has finished the work and risk using a freed connection. GM True ! i haven't seen it ! This design could serve several connections/threads at the same time. GM Thanks a lot ! GM -- GM Guillaume MAISON - [EMAIL PROTECTED] GM 83, Cours Victor Hugo GM 47000 AGEN GM Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 GM e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] ThttpServer and threading design
Dod a écrit : Hello Guillaume, Until know what I use to do is to create a worker thread and send jobs (with pointer to socket client object) and then worker send back a message to socket thread with pointer of data to send back to client. So all socket things is done from same thread. Dettaching clientsocket from socket thread to attach it into worker thread when starting lenghty operation is something I never did. What you're doing is transfering a socket from main thread context to your work thread context. My purpose is not the following. What i mean is executing all the SQL stuff within the thread, and the connection stuff within the main thread. When i meant attaching the socket it was not using the MultiThread property or the De/AttachThread methods. i just meant attach the socket reference in order to be used in the OnThreadTerminate event (which is in the main thread). I have one question regarding this... if some socket event come during the lengthly operation (OnDisconnect or OnDataAvailable for example), will they be triggered during operation or only at end of it ? If socket is MultiThread:=true it should use its own message queue so react instantly whenever the thread it is attached into is busy isn't it ? if my purpose was to use socket within a thread context, this should be, yes, a constraint to take into account. The design i provided in the first mail is meant precisely not to bother with such constraints. From Bjornar suggestion, if the client connection is closed, then all that has to be done is to stop/terminate the worker thread if active. Regards, -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] ThttpServer and threading design
Dod a écrit : Ok so you do nearly same as me. But at the end of threaded job I verify the client still exists before sending result. When a session connect I set a SessionID incremental counter in MySocketClient class because I noticed that same socket handle can be re-used by a next connection. So when I finish the job I just check if SessionID is still part of actual session's list. But setting a 'killed' value in working thread is also good. Yes. In fact, the more i work on the overall design, the more it looks like midware's one :) Except that i can't use midware ! Damn ! Thanks for your help ! Best regards, -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] [QUESTION] ThttpServer and threading design
What you're doing is transfering a socket from main thread context to your work thread context. My purpose is not the following. What i mean is executing all the SQL stuff within the thread, and the connection stuff within the main thread. That's what I do with my MidWare threaded TServerObject. You can apply the same logic to the HttpServer component. I have a class which manage a pool of threads. When a request comes in, I get a thread from the pool, adding a new one if necessary. The thread receive a reference to the socket component , this is important. The thread execute the lengthy database request and build the response message and pass it to the main thread for sending it back to the client. When the socket detect a session close, then it nullify the reference the thread has so that the thread know it has to throw away any data or pass it back to the main thread. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) 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] [QUESTION] ThttpServer and threading design
Hello Francois, Exactly what I do now, but what reference do you pass to thread ? At beginning I did it with socket.handle (if I remember well by it was long time ago) by I noticed that if during work job the socket is closed and a new connexion come, then it could happend that this new socket get same handle as previous closed one so my worker may sent back data to wrong client. That is why I know use an incremental SessionID counter that I pass to worker to be sure to never send data back to wrong socket and be sure to always get unique ID among thousand of connections. FP That's what I do with my MidWare threaded TServerObject. You can apply the same logic to the FP HttpServer component. FP I have a class which manage a pool of threads. When a request comes in, I get a thread from the FP pool, adding a new one if necessary. The thread receive a reference to the socket component , this FP is important. The thread execute the lengthy database request and build the response message and FP pass it to the main thread for sending it back to the client. FP When the socket detect a session close, then it nullify the reference the thread has so that the FP thread know it has to throw away any data or pass it back to the main thread. FP -- FP Contribute to the SSL Effort. Visit FP http://www.overbyte.be/eng/ssl.html FP -- FP [EMAIL PROTECTED] FP Author of ICS (Internet Component Suite, freeware) FP Author of MidWare (Multi-tier framework, freeware) FP 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] [QUESTION] ThttpServer and threading design
Francois Piette a écrit : That's what I do with my MidWare threaded TServerObject. You can apply the same logic to the HttpServer component. I have a class which manage a pool of threads. When a request comes in, I get a thread from the pool, adding a new one if necessary. The thread receive a reference to the socket component , this is important. The thread execute the lengthy database request and build the response message and pass it to the main thread for sending it back to the client. When the socket detect a session close, then it nullify the reference the thread has so that the thread know it has to throw away any data or pass it back to the main thread. that's what i'll almost implement. BTW, i think that, if the ICS Wiki project is realized, there should be a category that should present some design pattern to use with ICS components. May be i could help to write some of those articles :) Even, to explain the design patterns that are used internally by ICS :) Thanks for your help, Regards, -- Guillaume MAISON - [EMAIL PROTECTED] 83, Cours Victor Hugo 47000 AGEN Tél : 05 53 87 91 48 - Fax : 05 53 68 73 50 e-mail : [EMAIL PROTECTED] - Web : http://nauteus.com -- 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] Question How can I setup checkboxestoseetheFTP-Status
However the speed depends of course, if you have just a single instance, it makes no difference, but how do you realize multiple, concurrent i.e. FTP-dowloads in sync mode? You would have to go multithreaded, pooled or one thread per connection but that's definitely slower than having multiple instances in a single thread. Again not necessarily, I trigger activities off a timer and messages, and so a sync FTP download does not stop the time running other things at the same time, provided any 'waits' are calling ProcessMessages to keep things moving (and there are no sleeps). I only use threads for pings, since they are blocking. One application is doing once a second async comms at the same time as sync FTP downloads. I don't disagree that use of async events is better, particularly for servers, and I use them for simple socket applications that don't have complex states. Angus -- 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] Question How can I setupcheckboxestoseetheFTP-Status
Do you say that you are convinced MsgWaitForMultpleObjects() is faster than Sleep()and ProcessMessages; ;-) Both MsgWaitForMultpleObjects and Sleep seriously slow down a program that's trying to do multiple jobs at the same time. Angus -- 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] Question How can I setup checkboxes to see theFTP-Status
I'm coding with Delphi 2005. Win32 personnality ? Till now I don't see the ftp-status. I like to have 3 checkboxes for each status (Online, 421, Offline). If one status is true the checkbox for the status should be checked. I know that FTPCLI has a status-Option with a log. How can I do it easily to get the status to the checkboxes. Have you looked at the FtpTst sample program ? All messages from/to server are displayed. You have to parse those messages to update your UI if you don't want plain messages. -- [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] Question How can I setup checkboxes to seetheFTP-Status
I don't see any error-message. For example the FTP is not connected, delphi2005 gives me the error-message with the option to break or continue. i think i miss something. So what do I need minimal to get the error-messages? Use OnBgException event. Use Try/Except Use Application.OnException -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Mike McGreek [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, April 16, 2005 3:45 PM Subject: Re: [twsocket] Question How can I setup checkboxes to seetheFTP-Status Win32, Yes. I had a look into Your FTPTST example. So I need only the status-function. How do You display Your messages? I can't show the messages in my program. In FTPTST is a display-function. procedure Display(const Msg: String); procedure DisplayHandler(Sender: TObject; var Msg : String); procedure TFtpReceiveForm.Display(const Msg : String); var I : Integer; begin DisplayMemo.Lines.BeginUpdate; try if DisplayMemo.Lines.Count 200 then begin for I := 1 to 50 do DisplayMemo.Lines.Delete(0); end; DisplayMemo.Lines.Add(Msg); finally DisplayMemo.Lines.EndUpdate; {$IFNDEF VER80} SendMessage(DisplayMemo.Handle, EM_SCROLLCARET, 0, 0); {$ENDIF} end; end; procedure TFtpReceiveForm.DisplayHandler(Sender : TObject; var Msg : String); begin Display(Msg); end; I don't see any error-message. For example the FTP is not connected, delphi2005 gives me the error-message with the option to break or continue. i think i miss something. So what do I need minimal to get the error-messages? Send instant messages to your online friends http://uk.messenger.yahoo.com -- 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: [twsocket] Question How can I setup checkboxes to seetheFTP-Status
Mike McGreek wrote: You understand me wrong. I do the connect-call then the other calls. I want to know what I need minimal to get the Error-Messages and the normal messages from the server. Here a example: I connect to the server. The server send me 421 back. If it is 421 my program should wait 2 min for example. So I must log the message 421 in a edit or memo to phrase it. So I think I should do this so: memo1.lines.add(timetostr(time)+msg); msg will be the message form FTPCLI. ... or I'm on the wrong way? Send instant messages to your online friends http://uk.messenger.yahoo.com -- 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] Question How can I setup checkboxes to seetheFTP-Status
Arno, I think that will be the easiest way. I'll try it. I readed the whole code and understand it. It is realy good written. Also the infos about each function. Great work. It is more stabil than Indy10. I'll keep on trying ... Probably FtpCli.StatusCode is what you are looking for? Arno Garrels Send instant messages to your online friends http://uk.messenger.yahoo.com -- 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] Question How can I setup checkboxes toseetheFTP-Status
Mike McGreek wrote: Arno, I think that will be the easiest way. I'll try it. I readed the whole code and understand it. That's great, then you have probably realized that in comparison with Indy ICS requires a totaly different programming stile, since virtually anything is event-driven. Given you want best performance one should use the async/none-blocking methods, however in TFtpCli each method has also a blocking (sync) counterpart that allows you to code more like the Indy way (slow). Arno Garrels -- 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] Question How can I setup checkboxes toseetheFTP-Status
Given you want best performance one should use the async/none-blocking methods, however in TFtpCli each method has also a blocking (sync) counterpart that allows you to code more like the Indy way (slow). Indy might be slow, I really don't know, but I don't see using the sync methods in ICS provides any difference in performance to using the async versions, it's just a different way of programming (at least provided you remove or disable Sleep/MsgWaitForMultipleObjects). I use sync methods in most of my multi-tasking applications, and they work very nicely. They also make a program probably 10 times easier to develop and maintain that using async, since you don't need state flags all over the place to try and work out what you are supposed to do next in RequestDone. Angus -- 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] Question How can I setup checkboxestoseetheFTP-Status
Angus Robertson - Magenta Systems Ltd wrote: Given you want best performance one should use the async/none-blocking methods, however in TFtpCli each method has also a blocking (sync) counterpart that allows you to code more like the Indy way (slow). Indy might be slow, I really don't know, but I don't see using the sync methods in ICS provides any difference in performance to using the async versions, it's just a different way of programming (at least provided you remove or disable Sleep/MsgWaitForMultipleObjects). Indy is blocking, buggy, has a huge overhead and encapsulates too many things that I am able to control in ICS. However the speed depends of course, if you have just a single instance, it makes no difference, but how do you realize multiple, concurrent i.e. FTP-dowloads in sync mode? You would have to go multithreaded, pooled or one thread per connection but that's definitely slower than having multiple instances in a single thread. Arno Garrels I use sync methods in most of my multi-tasking applications, and they work very nicely. They also make a program probably 10 times easier to develop and maintain that using async, since you don't need state flags all over the place to try and work out what you are supposed to do next in RequestDone. Angus -- 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