> I got a timer event that calls a socket loop of the connected > people and sends message to each client and if the client is not > found it would close the person connection to socket. problem am > having when there a lot of people online the loop seams to bug > out and give access error the code am using is below any one got > any advice or a better way of doing what am trying to do?
Sending a string to a dead socket may result in timeouts. It would be much better to reverse the protocol so the client sends a keep alive packet once a minute if they are not otherwise sending stuff, which you record, then your timer loop only needs to check how long since they last sent something. This is how the ICS HTTP and FTP servers disconnect idle sessions. There is a TWSocketCounter class that provides LastAliveTick, LastRecvTick and LastSentTick for precisely this purpose. You need to call CreateCounter to create the counters for each client. Even with your existing protocol, you could check LastAliveTick anyway and skip sending anything if they've sent something recently, to reduce the workload. You can also send a threaded ICMP ping to the client to check the route, I do that before making a connection to avoid the timeouts of a failed connection, but it's not 100% reliable because some networks block pings. 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