Re: [twsocket] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
I could not use the component and WSocketServer WSocketThrdServer not know
how to use the event OnDataAvailable examples that have the error when
the POS Terminal (Client) connects to the server, he closes the connection
immediately and then not process the data .. . I saw nothing that works
directly on the event OnDataAvailable have any examples of using
WSocketThrdServer? as I told a client that uses the component WSocket not
of error, plus the client developed in C for POS terminals that problem
happens ...

Thank you again!


2013/4/26 Angus Robertson - Magenta Systems Ltd an...@magsys.co.uk

  I am not able to use the component TWSocketServer with POS
  terminals (do
  not have access to sources of client developed in C), the error
  occurs  after the connection OverbyteIcsWSocketS

 What error?


  I need to do is receive multiple simultaneous connections to these
  terminals make query on a sql server database and returns the
  contents

 You can not use threads with SocketServer client responses, although you
 can use a thread to prepare a response and send it from the main thread,
 look at the FTP server which uses threads to index directories and
 calculate MD5 hashes, but still uses SocketServer.

 My ICS web server is driven by a SQL database, but most queries takes 20
 to 100ms so I did not bother to use threads, effectively the server stops
 for that moment, but still supports 100 or more active sessions.

 If you really need client threads, you should be using TWSocketThrdServer.


 Angus





 --
 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] Close connection (destroy) idle clients

2013-04-30 Thread Angus Robertson - Magenta Systems Ltd
 I could not use the component and WSocketServer WSocketThrdServer 
 not know how to use the event OnDataAvailable examples that have

The SocketServer demo is OverbyteIcsTcpSrv.dpr, ThreadServer is
OverbyteIcsThrdSrvV3.dpr. 

You can also try TMagIpLog from:

http://www.magsys.co.uk/delphi/magics.asp

which is a combined client and server component designed for simple
telnet protocols, there is an EXE can you run to listen on your port and
it will display anything that arrives. 

All these demos illustrate the event OnDataAvailable 

Angus

--
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] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
Hello, I am using the example OverbyteIcsThrdSrvV3.dpr plus what happens is
that the wind ClientDisconnect is called before processing the received
data, and so the connection is lost and I can not communicate with the
client, it returned me the error 10053 as log below:

TcpSrv (c) 2005-2010 by François Piette. V3.00
  TWSocket (c) 1996-2012 Francois Piette V7.87
  TWSocketServer (c) 1999-2011 F. Piette V7.04
Waiting for clients ...
Client connected. Remote: 192.168.25.93/4634 Location:
192.168.25.66/5760ThrdID: $ 4,532 ThrdCnt: # 1
There is now 1 clients connected.
Received from 192.168.25.93: 'ACTION = SOLIC_FLUXO  ID_TERMINAL =
528-533-378  COD_EVENTO = 1579  TPEMISSAO = 0'
Client disconnecting: 192.168.25.93 Duration: 00:00:21 Error: 10053 ThrdID:
$ 4,532 ThrdCnt: # 1
There is now 0 clients connected.


2013/4/30 Angus Robertson - Magenta Systems Ltd an...@magsys.co.uk

  I could not use the component and WSocketServer WSocketThrdServer
  not know how to use the event OnDataAvailable examples that have

 The SocketServer demo is OverbyteIcsTcpSrv.dpr, ThreadServer is
 OverbyteIcsThrdSrvV3.dpr.

 You can also try TMagIpLog from:

 http://www.magsys.co.uk/delphi/magics.asp

 which is a combined client and server component designed for simple
 telnet protocols, there is an EXE can you run to listen on your port and
 it will display anything that arrives.

 All these demos illustrate the event OnDataAvailable

 Angus

 --
 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] Close connection (destroy) idle clients

2013-04-30 Thread François Piette
 Hello, I am using the example OverbyteIcsThrdSrvV3.dpr plus what happens
is that the wind 
 ClientDisconnect is called before processing the received data, and so the
connection is lost 
 and I can not communicate with the client, it returned me the error 10053
as log below:

TcpSrv (c) 2005-2010 by François Piette. V3.00
  TWSocket (c) 1996-2012 Francois Piette V7.87
  TWSocketServer (c) 1999-2011 F. Piette V7.04 Waiting for clients ...
Client connected. Remote: 192.168.25.93/4634 Location:
192.168.25.66/5760ThrdID: $ 4,532 ThrdCnt: # 1 There is now 1 clients
connected.
Received from 192.168.25.93: 'ACTION = SOLIC_FLUXO  ID_TERMINAL =
528-533-378  COD_EVENTO = 1579  TPEMISSAO = 0'
Client disconnecting: 192.168.25.93 Duration: 00:00:21 Error: 10053 ThrdID:
$ 4,532 ThrdCnt: # 1
There is now 0 clients connected.

As far as I understand, the client disconnect to fast, without waiting for
the server's answer. So you have to look at the client to understand why it
doesn't wait the response from the server.

Or maybe the client is not supposed to receive a reply from the server, in
which case it is perfectly normal to close the communication on his side.
And of course the server should not send any reply.

If I misunderstood your problem, please try to explain it using other words.
Don't forget to illustrate the protocol in use between client and server.


-- 
francois.pie...@overbyte.be
Embarcadero MVP
http://www.overbyte.be
http://francois-piette.blogspot.com




--
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] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
I'm using TCP for communication, I do not have access to the client source
to check, plus it works normally with INDY, and ISC component WSocket only
with WSocketServer WSocketThrdServer and that this problem occurs, it takes
is a message exchange (string) between client and server with multiple
clients connected simultaneously, the problem with the component WSocket
that is working is that if a customer taking disconnect the network cable,
I can not check if there is a socket opened in ClientThread to destroy it
and thereby leaving many threads created without ...

thanks for the help so far, will keep checking up with some solution to
this client.


2013/4/30 François Piette francois.pie...@skynet.be

  Hello, I am using the example OverbyteIcsThrdSrvV3.dpr plus what happens
 is that the wind
  ClientDisconnect is called before processing the received data, and so
 the
 connection is lost
  and I can not communicate with the client, it returned me the error 10053
 as log below:
 
 TcpSrv (c) 2005-2010 by François Piette. V3.00
   TWSocket (c) 1996-2012 Francois Piette V7.87
   TWSocketServer (c) 1999-2011 F. Piette V7.04 Waiting for clients ...
 Client connected. Remote: 192.168.25.93/4634 Location:
 192.168.25.66/5760ThrdID: $ 4,532 ThrdCnt: # 1 There is now 1 clients
 connected.
 Received from 192.168.25.93: 'ACTION = SOLIC_FLUXO  ID_TERMINAL =
 528-533-378  COD_EVENTO = 1579  TPEMISSAO = 0'
 Client disconnecting: 192.168.25.93 Duration: 00:00:21 Error: 10053
 ThrdID:
 $ 4,532 ThrdCnt: # 1
 There is now 0 clients connected.

 As far as I understand, the client disconnect to fast, without waiting for
 the server's answer. So you have to look at the client to understand why it
 doesn't wait the response from the server.

 Or maybe the client is not supposed to receive a reply from the server, in
 which case it is perfectly normal to close the communication on his side.
 And of course the server should not send any reply.

 If I misunderstood your problem, please try to explain it using other
 words.
 Don't forget to illustrate the protocol in use between client and server.


 --
 francois.pie...@overbyte.be
 Embarcadero MVP
 http://www.overbyte.be
 http://francois-piette.blogspot.com




 --
 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] Close connection (destroy) idle clients

2013-04-30 Thread François Piette
 WSocket only with WSocketServer WSocketThrdServer and that this problem
occurs, it takes is 
 a message exchange (string) between client and server with multiple
clients connected 
 simultaneously, the problem with the component WSocket that is working is
that if a 
 customer taking disconnect the network cable, I can not check if there is
a socket opened 
 in ClientThread to destroy it and thereby leaving many threads created
without ...

Is this the same issue as the one related in your previous message ? It
seems not. But this looks closer to the subject.

To close inactive clients, the easiest way is to record the last time a
client sent a request and periodically check the client list and close all
client which had no more activity since a give amount of time.

By the way, why are you using a multithread version ? usually, multithread
applied to simply do not scale very well. Using ICS, properly, you can
usually serve hundreds of client with only a single thread. It is a bad idea
to create a thread for each client, especially if most client are not really
active.

You should create a thread only to execute lengthy requests a client may
send. Any request which execute fast should not have his own thread. And of
course, you should not create and destroy threads but instead a thread pool.

Correctly handling multithreading is frequently difficult for the
unexperimented multithreading developer.

All this being said, I have not enough information to be able to give you
better advice. I can only stay general.

-- 
francois.pie...@overbyte.be
Embarcadero MVP
http://www.overbyte.be
http://francois-piette.blogspot.com







--
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] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
Thank you, you are helping me a lot, the client connects makes the request
and disconnects, does not keep the connection active for over 20s, this way
I will continue using TWSocket and I will check the time of the last
activity of each client connected and disconnect case has passed the
connection timeout, I'm doing based on the example MtSrv, would be the
best for my case?

Thank you for your attention and help!


2013/4/30 François Piette francois.pie...@skynet.be

  WSocket only with WSocketServer WSocketThrdServer and that this problem
 occurs, it takes is
  a message exchange (string) between client and server with multiple
 clients connected
  simultaneously, the problem with the component WSocket that is working is
 that if a
  customer taking disconnect the network cable, I can not check if there is
 a socket opened
  in ClientThread to destroy it and thereby leaving many threads created
 without ...

 Is this the same issue as the one related in your previous message ? It
 seems not. But this looks closer to the subject.

 To close inactive clients, the easiest way is to record the last time a
 client sent a request and periodically check the client list and close all
 client which had no more activity since a give amount of time.

 By the way, why are you using a multithread version ? usually, multithread
 applied to simply do not scale very well. Using ICS, properly, you can
 usually serve hundreds of client with only a single thread. It is a bad
 idea
 to create a thread for each client, especially if most client are not
 really
 active.

 You should create a thread only to execute lengthy requests a client may
 send. Any request which execute fast should not have his own thread. And of
 course, you should not create and destroy threads but instead a thread
 pool.

 Correctly handling multithreading is frequently difficult for the
 unexperimented multithreading developer.

 All this being said, I have not enough information to be able to give you
 better advice. I can only stay general.

 --
 francois.pie...@overbyte.be
 Embarcadero MVP
 http://www.overbyte.be
 http://francois-piette.blogspot.com







 --
 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] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
How to implement the time of the last action on the event and then check
OnDataAvailable?


2013/4/30 {Dark_Ducke} darkdu...@gmail.com

 Thank you, you are helping me a lot, the client connects makes the request
 and disconnects, does not keep the connection active for over 20s, this way
 I will continue using TWSocket and I will check the time of the last
 activity of each client connected and disconnect case has passed the
 connection timeout, I'm doing based on the example MtSrv, would be the
 best for my case?

 Thank you for your attention and help!


 2013/4/30 François Piette francois.pie...@skynet.be

  WSocket only with WSocketServer WSocketThrdServer and that this problem
 occurs, it takes is
  a message exchange (string) between client and server with multiple
 clients connected
  simultaneously, the problem with the component WSocket that is working
 is
 that if a
  customer taking disconnect the network cable, I can not check if there
 is
 a socket opened
  in ClientThread to destroy it and thereby leaving many threads created
 without ...

 Is this the same issue as the one related in your previous message ? It
 seems not. But this looks closer to the subject.

 To close inactive clients, the easiest way is to record the last time a
 client sent a request and periodically check the client list and close all
 client which had no more activity since a give amount of time.

 By the way, why are you using a multithread version ? usually, multithread
 applied to simply do not scale very well. Using ICS, properly, you can
 usually serve hundreds of client with only a single thread. It is a bad
 idea
 to create a thread for each client, especially if most client are not
 really
 active.

 You should create a thread only to execute lengthy requests a client may
 send. Any request which execute fast should not have his own thread. And
 of
 course, you should not create and destroy threads but instead a thread
 pool.

 Correctly handling multithreading is frequently difficult for the
 unexperimented multithreading developer.

 All this being said, I have not enough information to be able to give you
 better advice. I can only stay general.

 --
 francois.pie...@overbyte.be
 Embarcadero MVP
 http://www.overbyte.be
 http://francois-piette.blogspot.com







 --
 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] Close connection (destroy) idle clients

2013-04-30 Thread Angus Robertson - Magenta Systems Ltd
 Hello, I am using the example OverbyteIcsThrdSrvV3.dpr plus what 
 happens is that the wind ClientDisconnect is called before
 processing the received data, and so the connection is lost 

I assume you have turned off the default banner that the server component
sends upon answer (set Banner:='';), that will upset clients expecting a
specific response. 

Have you tried the TMagIpLog demo?   It is very simple, and very reliable.


You can also try using a simple client OverbyteIcsCliDemo.dpr to connect
to your server so you can see exactly what happens on connect.  When
writing server protocols, it's often useful to have a test client
application to methodically test the commands you implement, with false
or corrupted data for instance, which is hard to test with your 'real'
client.  

Angus

--
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] Close connection (destroy) idle clients

2013-04-30 Thread François Piette
 How to implement the time of the last action on the event and then check
OnDataAvailable?

Assuming you use ThrdSrv: Add a filed in the class TThrdSrvClient which is
instanciated for each client connecting. Update this filed for datetime of
the last message sent by the client, probably from the Datavaialble event
hanlder.

Then from the outside, for example using a TTimer triggered avery 30 sec,
iterate thru the client list of the server component and check the last
message datetime of each client, calling Abort should that time be greater
than a given timeout value.

-- 
francois.pie...@overbyte.be
Embarcadero MVP
http://www.overbyte.be
http://francois-piette.blogspot.com


--
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] Close connection (destroy) idle clients

2013-04-30 Thread François Piette
 I'm doing based on the example MtSrv, would be the best for my case?

Have you looked at the comments in front of MtSrv sample ?
Here is is:
    MtSrv is an old sample program 
   It works OK, but you should use ThrdSrv project 

I will assume you'll use ThrdSrv sample program.

-- 
francois.pie...@overbyte.be
Embarcadero MVP
http://www.overbyte.be
http://francois-piette.blogspot.com





--
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] Close connection (destroy) idle clients

2013-04-30 Thread {Dark_Ducke}
Could use ThrdServer example, the problem was solved with
WSocketServer1.Banner: =''; now I can not receive data, by setting longer
just LINEMODE = FALSE, and after a few connections, does not enter the
event OnDataAvailable when LINEMODE = TRUE event OnDataAvailable is
never triggered ... have any idea what can be? I'm using ReceiveStr to
receive the data, the more the example only shows how to receive LINEMODE =
TRUE;

Thank you again!


2013/4/30 François Piette francois.pie...@skynet.be

  I'm doing based on the example MtSrv, would be the best for my case?

 Have you looked at the comments in front of MtSrv sample ?
 Here is is:
     MtSrv is an old sample program 
    It works OK, but you should use ThrdSrv project 

 I will assume you'll use ThrdSrv sample program.

 --
 francois.pie...@overbyte.be
 Embarcadero MVP
 http://www.overbyte.be
 http://francois-piette.blogspot.com





 --
 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