Re: [twsocket] TWsocket server client list Error

2006-10-13 Thread Miguel Ca

hi Arno

I am running ICS in a nt service and i am using multi threading but the 
socketservers is in the main thread. The threads only do some work with a 
database and validation of the information received from the machines and in 
the end the threads make a send call.




Miguel Angel Cañas C.





From: Arno Garrels [EMAIL PROTECTED]
Reply-To: ICS support mailing twsocket@elists.org
To: ICS support mailing twsocket@elists.org
Subject: Re: [twsocket] TWsocket server client list Error
Date: Thu, 12 Oct 2006 19:03:52 +0200

Miguel, are you running ICS in a multi-threaded application
or in a NT-Service?

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html


Wilfried Mestdagh wrote:
 Hello Miguel,

 No not configuration. the socket handle is probably somewhere
 overwritten. Please check carefull all variable usage, and specially
 arrays that may got overrun.

 My TWsocketServer object :

 LocalAddr = '0.0.0.0'//set in runtime
 LocalPort = '0' //set in runtime

 Try to not set it, you never know. However I dont think it can cause
 the
 behavour you have.

 OnDataSent = WSocketServerExDataSent
 OnSessionClosed = WSocketServerExSessionClosed

 Set this in comment as it will never fire on server socket.

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

 Thursday, October 12, 2006, 06:58, Miguel Cañas wrote:

 Hi Wilfried

 Sorry but I didn-t have time to do a test program, I am in a dead
 line and I have another errors to fix too but this one is critical
 to me because the service is starting to loose connections.

 Let me explain better:

 1. The connections Startt to grow because of the processing time, the
 service is processing as fast as possible.
 2. I have like 50 to 60 connections in the client list
 (Wsocketserver.clientcount)
 3. I have the first Error 10038 in function Disconnect (closesocket)
 Socket operation on non-socket
 4. I?m using TcpView
 (http://www.sysinternals.com/Utilities/TcpView.html)
 and I saw that the new connection got into the list of the program
 but next disappeared and my program didn?t run the onConnect event,
 at least no t the part that is into my program.
 5. After that I saw the connection with no IP no port info and the
 Hsokcet value = -1.

 Could it  be a configuration problem ? in the TWsocket server ? or
 in the server PC?

 My TWsocketServer object :

 LineMode = False
 LineLimit = 65536
 LineEnd = #13#10
 LineEcho = False
 LineEdit = False
 Proto = 'tcp'
 LocalAddr = '0.0.0.0'//set in runtime
 LocalPort = '0' //set in runtime
 LastError = 0
 MultiThreaded = False
 MultiCast = False
 MultiCastIpTTL = 1
 ReuseAddr = False
 ComponentOptions = []
 ListenBacklog = 1000 //s
 ReqVerLow = 1
 ReqVerHigh = 1
 OnDataSent = WSocketServerExDataSent
 OnSessionClosed = WSocketServerExSessionClosed
 OnBgException = WSocketServerExBgException
 FlushTimeout = 60
 SendFlags = wsSendNormal
 LingerOnOff = wsLingerOn
 LingerTimeout = 0
 KeepAliveOnOff = wsKeepAliveOnSystem
 KeepAliveTime = 3
 KeepAliveInterval = 1000
 SocksLevel = '5'
 SocksAuthentication = socksNoAuthentication
 BannerTooBusy = 'Sorry, too many clients'
 MaxClients = 300
 OnClientDisconnect = WSocketServerExClientDisconnect
 OnClientConnect = WSocketServerExClientConnect


 Miguel Angel Cañas C.




 From: Wilfried Mestdagh [EMAIL PROTECTED]
 Reply-To: ICS support mailing twsocket@elists.org
 To: ICS support mailing twsocket@elists.org
 Subject: Re: [twsocket] TWsocket server client list Error
 Date: Fri, 6 Oct 2006 12:35:51 +0200

 Hello Miguel,

 Your code looks OK. Very strange this behavour. Can you make a
 simple demo (GUI) project to demonstrate the behavour ?  Possible I
 have time this weekend to investigate it.

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

 Friday, October 6, 2006, 03:25, Miguel Cañas wrote:

 Hello Wilfried

 Today i made some test and the results are not good for me. I
 colud no t find the error that triggger the exceptior but i find
 that for each exception i have an 'empty' connection (no ip no
 port).

 I will make a little explanacion of my code. My service is a tcp
 server very similar to the example that comes with ICS componets.

 My code look like this

 WSocketServerExClientConnect()
   
 OnDataAvailable := ClientDataAvailable;
 OnBgException := ClientBgException;
 ConnectTime := Time
 

 writeinTxtFile( '--Conexiones Activas : ' + IntToStr(
 WSocketServerEx.ClientCount ), true );
 for i := 0 to WSocketServerEx.ClientCount - 1 do
 begin
   writeinTxtFile( Format( '--Activa[%d] IP [%s] PORT [%s]',
 [ i, WSocketServerEx.client[ i ].getPeerAddr,
 WSocketServerEx.client[ i ].getPeerport ]
 ) );
  

Re: [twsocket] TWsocket server client list Error

2006-10-13 Thread Arno Garrels
Miguel Cañas wrote:
 hi Arno
 
 I am running ICS in a nt service and i am using multi threading but
 the socketservers is in the main thread. 

If you use V6 there may be collisions with window messages in the beginning 
of range WM_USER posted to the same _thread where TWSocketServer created it's
hidden window, are you using V6? Do you use PostThreadMessage? 
 
Do you create the TWSocketServer instance in OnCreate of
TService? Only if you create it in TService.OnStart it'd run in the
service thread. 

 The threads only do some
 work with a database and validation of the information received from
 the machines and in the end the threads make a send call.

Do you access the TWSocketClients from the worker threads directly, or
do you post a messsage with the worker thread result to the thread where
the TWSocketServer and its clients are running in? 

If it's not the message-collision-problem of V6, it may have 
to do with improper use of ICS in a multi-threaded env.,
beside the possible reasons Wilfried and Francois already mentioned.

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

 
 
 
 Miguel Angel Cañas C.
 
 
 
 
 From: Arno Garrels [EMAIL PROTECTED]
 Reply-To: ICS support mailing twsocket@elists.org
 To: ICS support mailing twsocket@elists.org
 Subject: Re: [twsocket] TWsocket server client list Error
 Date: Thu, 12 Oct 2006 19:03:52 +0200
 
 Miguel, are you running ICS in a multi-threaded application
 or in a NT-Service?
 
 ---
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 Wilfried Mestdagh wrote:
 Hello Miguel,
 
 No not configuration. the socket handle is probably somewhere
 overwritten. Please check carefull all variable usage, and
 specially arrays that may got overrun.
 
 My TWsocketServer object :
 
 LocalAddr = '0.0.0.0'//set in runtime
 LocalPort = '0' //set in runtime
 
 Try to not set it, you never know. However I dont think it can
 cause the
 behavour you have.
 
 OnDataSent = WSocketServerExDataSent
 OnSessionClosed = WSocketServerExSessionClosed
 
 Set this in comment as it will never fire on server socket.
 
 ---
 Rgds, Wilfried [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 http://www.mestdagh.biz
 
 Thursday, October 12, 2006, 06:58, Miguel Cañas wrote:
 
 Hi Wilfried
 
 Sorry but I didn-t have time to do a test program, I am in a dead
 line and I have another errors to fix too but this one is critical
 to me because the service is starting to loose connections.
 
 Let me explain better:
 
 1. The connections Startt to grow because of the processing time,
 the service is processing as fast as possible.
 2. I have like 50 to 60 connections in the client list
 (Wsocketserver.clientcount)
 3. I have the first Error 10038 in function Disconnect
 (closesocket) Socket operation on non-socket
 4. I?m using TcpView
 (http://www.sysinternals.com/Utilities/TcpView.html)
 and I saw that the new connection got into the list of the program
 but next disappeared and my program didn?t run the onConnect
 event, at least no t the part that is into my program.
 5. After that I saw the connection with no IP no port info and the
 Hsokcet value = -1.
 
 Could it  be a configuration problem ? in the TWsocket server ? or
 in the server PC?
 
 My TWsocketServer object :
 
 LineMode = False
 LineLimit = 65536
 LineEnd = #13#10
 LineEcho = False
 LineEdit = False
 Proto = 'tcp'
 LocalAddr = '0.0.0.0'//set in runtime
 LocalPort = '0' //set in runtime
 LastError = 0
 MultiThreaded = False
 MultiCast = False
 MultiCastIpTTL = 1
 ReuseAddr = False
 ComponentOptions = []
 ListenBacklog = 1000 //s
 ReqVerLow = 1
 ReqVerHigh = 1
 OnDataSent = WSocketServerExDataSent
 OnSessionClosed = WSocketServerExSessionClosed
 OnBgException = WSocketServerExBgException
 FlushTimeout = 60
 SendFlags = wsSendNormal
 LingerOnOff = wsLingerOn
 LingerTimeout = 0
 KeepAliveOnOff = wsKeepAliveOnSystem
 KeepAliveTime = 3
 KeepAliveInterval = 1000
 SocksLevel = '5'
 SocksAuthentication = socksNoAuthentication
 BannerTooBusy = 'Sorry, too many clients'
 MaxClients = 300
 OnClientDisconnect = WSocketServerExClientDisconnect
 OnClientConnect = WSocketServerExClientConnect
 
 
 Miguel Angel Cañas C.
 
 
 
 
 From: Wilfried Mestdagh [EMAIL PROTECTED]
 Reply-To: ICS support mailing twsocket@elists.org
 To: ICS support mailing twsocket@elists.org
 Subject: Re: [twsocket] TWsocket server client list Error
 Date: Fri, 6 Oct 2006 12:35:51 +0200
 
 Hello Miguel,
 
 Your code looks OK. Very strange this behavour. Can you make a
 simple demo (GUI) project to demonstrate the behavour ? 
 Possible I have time this weekend to investigate it.
 
 ---
 Rgds, Wilfried [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 http://www.mestdagh.biz
 
 Friday, October 6, 2006, 03:25, Miguel Cañas wrote:
 
 Hello Wilfried