Re: [twsocket] multithread server
hi, I always call Receive (even if RcvdCount returns zero). When RcvdCount returns zero then Receive returns -1 value. Is it normal? What is property Multithreaded in TWServerSocket? Should it be set to TRUE? In demo application property is set to FALSE and only client sockets are set to TRUE. Now I have no idea where is problem with service hanging. Any idea where to look is welcome. Thanks Lukas Skala Dne 17.8.2011 18:18, Wilfried Mestdagh napsal(a): Hi, If OnDataAvailable triggers then you have to try to receive data, even if RcvdCount (wich is unreliable) returns 0. If you don't receive then OnDataAvailable will be called again in a closed loop en that is probably what happens. -- lukas skala envinet a.s. divize projektu a inzenyringu (project and engineering division) modrinova 1094 674 01 trebic tel: +420 568 409 862 (811) fax: +420 568 409 875 gsm: +420 724 461 062 icq: 66842878 eml: lukas.sk...@envinet.cz, luky.sk...@gmail.com www: http://envinet.cz -- 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] multithread server
Hi, When receive returns -1 then it indicate an error, but you don't have to worry about it. If MultiThread is True then TWSocket uses his own message pump. You can use it yourself also or override it. If OnDataAvailable is called in a closed loop then there is something wrong with winsock. You tell that it happens after a while when many clients connecting (and disconnecting ???). Is this predictable? Is it possible you have many sockets in TIME_WAIT state or that you have run out of non-pagable memory? You can check the former with 'netstat -a'. The latter with task manager. Note that a socket uses 10kb (or more depeniding on traffic), that non-pagable memory is maximum 1/8 of total real memory (not virtual). Have you the same problem if you run the same application in a GUI or console application? You can set wsoNoReceivedLoop for each client then OnDataAvailable is not called in closed loop but with a message handler. Eventually more easy to debug? -- mvg, Wilfried http://www.mestdagh.biz http://www.comfortsoftware.be http://www.expertsoftware.be -Oorspronkelijk bericht- Van: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] Namens Lukáš Skála Verzonden: donderdag 18 augustus 2011 8:05 Aan: twsocket@elists.org Onderwerp: Re: [twsocket] multithread server hi, I always call Receive (even if RcvdCount returns zero). When RcvdCount returns zero then Receive returns -1 value. Is it normal? What is property Multithreaded in TWServerSocket? Should it be set to TRUE? In demo application property is set to FALSE and only client sockets are set to TRUE. Now I have no idea where is problem with service hanging. Any idea where to look is welcome. Thanks Lukas Skala Dne 17.8.2011 18:18, Wilfried Mestdagh napsal(a): Hi, If OnDataAvailable triggers then you have to try to receive data, even if RcvdCount (wich is unreliable) returns 0. If you don't receive then OnDataAvailable will be called again in a closed loop en that is probably what happens. -- lukas skala envinet a.s. divize projektu a inzenyringu (project and engineering division) modrinova 1094 674 01 trebic tel: +420 568 409 862 (811) fax: +420 568 409 875 gsm: +420 724 461 062 icq: 66842878 eml: lukas.sk...@envinet.cz, luky.sk...@gmail.com www: http://envinet.cz -- 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] multithread server
hi, thank for reply. there are about 150 clients (in average) connected at the same time. sometimes program hang after 15 minutes of running, sometimes after several hours. I think there is no memory problem because server has a lot of memory and when I check it using taskmanager there is a lot of free memory (service itself is consuming about 58 mb of RAM), procesor time of the process is below 1%. There are about 10 connection in TIME_WAIT state. Values are taken when service is running without problem, I will check it again when it will hang. I am not sure what does TIME_WAIT means - by googling I have found that it is closing socket waiting for final messages handshaking - is it true? I hope it is not my problem because if client is not active (1 minute) it is disconnected by the server. Is it possible that sockets which were not correctly disconnected (e.g. clients was disconnected from network) will stay in TIME_WAIT state? Even when server close them explicitly after communication timeout? Service is running on more servers and it seems to work fine with less clients. I have problem only on one server - unfortunatelly there is no chance to debug service (only write to log is possible). I will try to test in GUI application. I did some test and now I have 2 version: version 1: incoming data are received in main thread and are written to buffer of client, client has own thread to process data in buffer version 2: data are received in client thread (in same way as in demo thread application) It seems version 1 is more stable but it will hang too. Processing of data is done by the same procedures so I hope there is no difference. Lukas Dne 18.8.2011 11:26, Wilfried Mestdagh napsal(a): Hi, When receive returns -1 then it indicate an error, but you don't have to worry about it. If MultiThread is True then TWSocket uses his own message pump. You can use it yourself also or override it. If OnDataAvailable is called in a closed loop then there is something wrong with winsock. You tell that it happens after a while when many clients connecting (and disconnecting ???). Is this predictable? Is it possible you have many sockets in TIME_WAIT state or that you have run out of non-pagable memory? You can check the former with 'netstat -a'. The latter with task manager. Note that a socket uses 10kb (or more depeniding on traffic), that non-pagable memory is maximum 1/8 of total real memory (not virtual). Have you the same problem if you run the same application in a GUI or console application? You can set wsoNoReceivedLoop for each client then OnDataAvailable is not called in closed loop but with a message handler. Eventually more easy to debug? -- lukas skala envinet a.s. divize projektu a inzenyringu (project and engineering division) modrinova 1094 674 01 trebic tel: +420 568 409 862 (811) fax: +420 568 409 875 gsm: +420 724 461 062 icq: 66842878 eml: lukas.sk...@envinet.cz, luky.sk...@gmail.com www: http://envinet.cz -- 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] SSL and TLS for TSmtpCli
Arno - or Encrypted Connection: SSL Port: 465 This is commonly SSL-type Implicit (TLS Connection). The difference between Implicit and Explicit is that Implicit establishes a secure SSL/TLS connection and Explicit starts with a plain text connection that is turned into a secure connection later when the client sends the STARTTLS command. So, how would I use this method Implicit (TLS Connection) in TSmtpCli? For example, if I wish to send using: Encrypted Connection: TLS Port: 587 That port can be used if the ISP has blocked SMTP port #25 and the mailserver services port #587 as well. Such as smtp.googlemail.com. The SSL-type on that port is commonly Explicit (STARTTLS). And how would I use this method in TSmtpCli? Instead of TSmtpCli you have to use TSslSmtpCli plus a linked TSslContext. Take a look at the OverbyteIcsSslMailSnd sample in ICS sub directory SslInternet, get a free GMail account and play with the demo. And don't forget to download the OpenSSL libraries from http://wiki.overbyte.be/wiki/index.php/ICS_Download. So, then a few more questions: 1. If my app is compiled in Delphi 7 32-bit, but have end-users that have both 32-bit and 64-bit Windows, would I use the OpenSSL Win32 binaries? Would they work on both platforms? 2. For the end user, if they chose Implicit (TLS Connection) or Explicit (STARTTLS) to send, I would not want them to have to fill in (or know about) the various SSLContext parameters (Verify Peer, CA File, CA Path, Cert File, Key File, Pass Phrase). What should I use for the default values for these? 3. For my app distribution, would I simply include libeay32.dll and ssleay32.dll in the application directory? Thanks, -- Neal -- 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