> This new version has presented me with a problem. I can > successfully connect to the first device in the list, and send > the command in the OnConnected event. Through reading comments in > the source, I understand that the problems originated with the > way I'm handling this. > > After the first connect, I try to do the next, which, I can see, > is the problem. I cannot change the address because that original > connection is still open.
You are using async functions, and trying to start a second connection on the socket before the first has closed. You either need to check in your loop that the socket state is closed already and wait until it is, or create an array of TWSockets so you can send these several messages in parallel. The big problem with TCP/IP is connection timeouts, it will usually wait 30 to 60 seconds attempting to make a connection before giving an error, which can slow down your messaging dramatically with a single socket. So multiple sockets is the way to go. You don't say how many devices you are dealing with, if it's dozens then one wsocket each is trivial, if it's hundreds or thousands you probably want to create a socket pool of maybe 100 wsockets and use them as they come free. Windows can only open so many new sockets per second, particularly if you are using SSL, thus the pool. All the sockets can share the same event handlers, when you create them set the Tag property to the counter number and check Tag in the event so you know what data to send. 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