Re: [twsocket] When receiving UDP datas, find if there were sent through a broadcast
I don't think this exists. However, I see two solutions for your problem: One easy and one more complex. 1) Easy: In the data packet you send, add the server address. Those not having that address will then easily detected. This is easy but required to somewhat change the protocol you use and this may not be possible for you. Good news, i found out that in my data packets, i had already a flag for that ! 2) Complex: Use a second TWSocket in raw mode to get hand on all packets. You can then peek in the raw packet to find the destination address which is 255.255.255.255. Complex, i agree -- 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] When receiving UDP datas, find if there were sent through a broadcast
>> I don't believe there is anything in the IP protocol that will >> identify a broadcast > If not, is there a flag somewhere in twsocket to tell an UDP socket > to ignore clients who knocks on a given port with a 255.255.255.255 address ? I don't think this exists. However, I see two solutions for your problem: One easy and one more complex. 1) Easy: In the data packet you send, add the server address. Those not having that address will then easily detected. This is easy but required to somewhat change the protocol you use and this may not be possible for you. 2) Complex: Use a second TWSocket in raw mode to get hand on all packets. You can then peek in the raw packet to find the destination address which is 255.255.255.255. -- 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] Multiple TCp clients
> Make sense but if you have a few TWSocets running at the same time and from every > connection writing to a shared TMemo you do not need to synchronize it somehow ? If you application is single threaded, no you don't need any synchronization, it is built-in by Windows message queue system. If your application is multithreaded, remember you can NOT access a TMemo from code executed in the context of a thread. You must use a mechanism to make TMemo updated in the context of the main thread. Synchronize is one [poor but easy] method of doing data. > OK, maybe my problem was different. I think so. > Thanks for elaborating this. See my other messages. -- 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] Multiple TCp clients
> It turns out that instrument response (every command is echoed back from the > instrument > along with status information) to a command is sometimes slow (up to 7 > seconds) > when I switch between instruments but this could well be an instrument issue Not sure I fully understand how you switch between instruments. If you break the connection each time (that is use the same TWSocket for all instruments), that may be the issue. Establishing a connection could take some significant time for slow devices. Just use a different TWSocket for each instruments, keep the connection oened and keep all TWSockets in a list or array as explained before. -- 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] Multiple TCp clients
Hi Lusty use f.e. wireshark ( http://www.wireshark.org/ ) to capture all packets "sent to" and "received from" your machines. Then you'll know if the 7 sec delay is a problem caused by your machines or by your code ;-). Regards Michael - Original Message - From: "Christopher Lusty" To: "ICS support mailing" Sent: Wednesday, February 26, 2014 1:53 PM Subject: Re: [twsocket] Multiple TCp clients Sorry about the incomplete explanation. It turns out that I had made an error and I was not allowing devices to respond every time before attempting to switch to another device - problem solved It turns out that instrument response (every command is echoed back from the instrument along with status information) to a command is sometimes slow (up to 7 seconds) when I switch between instruments but this could well be an instrument issue - for that, I have to visit with the manufacturer, they have more sophisticated testing equipment. Many thanks to all for the help. Lusty -Original Message- From: François Piette Sent: Tuesday, February 25, 2014 1:52 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients By 'bogged down' I mean that I can send and receive, alternating instruments but eventually the instruments (or the software) stop working correctly You have to better described "stop working correctly" if you want to significant help. What happens (or doesn't)? Is there any error code or exception? Put breakpoint, add display messages and all kind of debugging stuff. Do you have a postcard from Orillia, Ontario, Canada yet? Honestly, I can't tell you: I have received more than 4000 postcards for ICS registration. Send yours :-) -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be http://francois-piette.blogspot.com -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Christopher Lusty Envoyé : mardi 25 février 2014 19:27 À : ICS support mailing Objet : Re: [twsocket] Multiple TCp clients Thank you Francois, I was considering trying the array but wasn't sure that it would improve my results - having a single event handler is an excellent idea. By 'bogged down' I mean that I can send and receive, alternating instruments but eventually the instruments (or the software) stop working correctly - my guess is that using only one OndataReceive event will so a long way to resolving this Do you have a postcard from Orillia, Ontario, Canada yet? Regards Lusty -Original Message- From: François Piette Sent: Tuesday, February 25, 2014 1:07 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients Hello Chris, Don't use TWSocketServer. You should create an array (or a list or any collection you like) or TWSocket components. Then connect each TWSocket to his own instrument. You may use the same event handlers for all the TWSocket, simply use the Sender argument in each event to now who is who. All the sockets will work in parallel without any problem, without using thread and without requiring any synchronization with GUI components. If I leave both instruments connected the system runs for a bit but eventually gets bogged down. Not sure by what you mean by "bogged down". Ru your app under the debugger and report any exception. Also use madExcept to catch many errors with memory allocation and things like using freed objects and so on. -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be http://francois-piette.blogspot.com -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Christopher Lusty Envoyé : lundi 24 février 2014 22:38 À : twsocket@lists.elists.org Objet : [twsocket] Multiple TCp clients Hello all, I am trying to interface with some laboratory instruments, previously we used RS-232, now we are working on the next generation of machines The instruments act as servers, I have established reliable communications with each of the instruments as individual units using WSocket as a client. Now, I would like to set it up such that I can talk to each instrument in turn (it is never necessary to talk to more than one machine at a time). As an experiment I have built a small app with two TWServers on board, each is connected to buttons to dis/connect, send the contents of an edit box and place the results in a memo. Each client represents a different instrument. The setup works reasonably well if I connect-send-disconnect each instrument in turn. If I leave both instruments connected the system runs for a bit but eventually gets bogged down. I have no problem with having to make and break when I switch machines except for the fact that sometimes the reconnect can take a few seconds which, of course, slows things. Any suggestions for this TCP newbie as to how to use multiple clients within one piece of software would be greatly appreciated. I’d
Re: [twsocket] Multiple TCp clients
Sorry about the incomplete explanation. It turns out that I had made an error and I was not allowing devices to respond every time before attempting to switch to another device - problem solved It turns out that instrument response (every command is echoed back from the instrument along with status information) to a command is sometimes slow (up to 7 seconds) when I switch between instruments but this could well be an instrument issue - for that, I have to visit with the manufacturer, they have more sophisticated testing equipment. Many thanks to all for the help. Lusty -Original Message- From: François Piette Sent: Tuesday, February 25, 2014 1:52 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients By 'bogged down' I mean that I can send and receive, alternating instruments but eventually the instruments (or the software) stop working correctly You have to better described "stop working correctly" if you want to significant help. What happens (or doesn't)? Is there any error code or exception? Put breakpoint, add display messages and all kind of debugging stuff. Do you have a postcard from Orillia, Ontario, Canada yet? Honestly, I can't tell you: I have received more than 4000 postcards for ICS registration. Send yours :-) -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be http://francois-piette.blogspot.com -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Christopher Lusty Envoyé : mardi 25 février 2014 19:27 À : ICS support mailing Objet : Re: [twsocket] Multiple TCp clients Thank you Francois, I was considering trying the array but wasn't sure that it would improve my results - having a single event handler is an excellent idea. By 'bogged down' I mean that I can send and receive, alternating instruments but eventually the instruments (or the software) stop working correctly - my guess is that using only one OndataReceive event will so a long way to resolving this Do you have a postcard from Orillia, Ontario, Canada yet? Regards Lusty -Original Message- From: François Piette Sent: Tuesday, February 25, 2014 1:07 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients Hello Chris, Don't use TWSocketServer. You should create an array (or a list or any collection you like) or TWSocket components. Then connect each TWSocket to his own instrument. You may use the same event handlers for all the TWSocket, simply use the Sender argument in each event to now who is who. All the sockets will work in parallel without any problem, without using thread and without requiring any synchronization with GUI components. If I leave both instruments connected the system runs for a bit but eventually gets bogged down. Not sure by what you mean by "bogged down". Ru your app under the debugger and report any exception. Also use madExcept to catch many errors with memory allocation and things like using freed objects and so on. -- francois.pie...@overbyte.be Embarcadero MVP http://www.overbyte.be http://francois-piette.blogspot.com -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Christopher Lusty Envoyé : lundi 24 février 2014 22:38 À : twsocket@lists.elists.org Objet : [twsocket] Multiple TCp clients Hello all, I am trying to interface with some laboratory instruments, previously we used RS-232, now we are working on the next generation of machines The instruments act as servers, I have established reliable communications with each of the instruments as individual units using WSocket as a client. Now, I would like to set it up such that I can talk to each instrument in turn (it is never necessary to talk to more than one machine at a time). As an experiment I have built a small app with two TWServers on board, each is connected to buttons to dis/connect, send the contents of an edit box and place the results in a memo. Each client represents a different instrument. The setup works reasonably well if I connect-send-disconnect each instrument in turn. If I leave both instruments connected the system runs for a bit but eventually gets bogged down. I have no problem with having to make and break when I switch machines except for the fact that sometimes the reconnect can take a few seconds which, of course, slows things. Any suggestions for this TCP newbie as to how to use multiple clients within one piece of software would be greatly appreciated. I’d like to avoid threading. BTW – compiler is Delphi 7 (soon to be ported to XE2) Best regards Chris Lusty (first time poster) C.W. Lusty, PEng MBA Hinterland Software Ltd. Software manufacturers for the PC-Titrate family of products www.titrate.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] Multiple TCp clients
Hi Noam ...definitely no need to synchronize in a "single threaded app". Multi threaded: Main thread: Just add content to TMemo Other threads: Use synchronize (Executes a method call within the main thread) http://docwiki.embarcadero.com/Libraries/XE2/en/System.Classes.TThread.Synchronize Regards Michael - Original Message - From: "Noam weissman" To: "ICS support mailing" Sent: Wednesday, February 26, 2014 9:49 AM Subject: Re: [twsocket] Multiple TCp clients Hi, OK... Make sense but if you have a few TWSocets running at the same time and from every connection writing to a shared TMemo you do not need to synchronize it somehow ? OK, maybe my problem was different. Thanks for elaborating this. BR, Noam. -Original Message- From: TWSocket on behalf of François Piette Sent: Tue 2/25/2014 10:41 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients Can you please explain "there is definitely no such issue" ? I had a problem similar to this: I had a thread sending ping's to a list of IP's to check if devices are online. Please read again what I said: His program isn't multithreaded. If you use threads, then you can NOT acces any GUI item - such as a TMemo - from your thread. VCL is not "thread safe". I was told by a friend that the reason for that happening is that window is not an RT OS and will time slice the operation. This is not related at all to a real time operating system or not. Am I missing here something ? I don't know. Maybe you forgot that TWSocket component multitask without using threads. It simply uses events. And as such don't need to use synchronization objects. Of course if you use TWSocket in a thread, you are back to the difficulties of multithreading. And you may actually built a slower application to make a long story short. -- 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 This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. -- 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] When receiving UDP datas, find if there were sent through a broadcast
> If not, is there a flag somewhere in twsocket to tell an UDP > socket to ignore clients who knocks on a given port with a > 255.255.255.255 address ? The only addresses provided by the protocol are source and destination, I don't know broadcasting is implemented, but would assume it's down to ARP tables of MAC addresses on the LAN. 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] Multiple TCp clients
Hi, OK... Make sense but if you have a few TWSocets running at the same time and from every connection writing to a shared TMemo you do not need to synchronize it somehow ? OK, maybe my problem was different. Thanks for elaborating this. BR, Noam. -Original Message- From: TWSocket on behalf of François Piette Sent: Tue 2/25/2014 10:41 PM To: 'ICS support mailing' Subject: Re: [twsocket] Multiple TCp clients > Can you please explain "there is definitely no such issue" ? > I had a problem similar to this: > I had a thread sending ping's to a list of IP's to check if devices are online. Please read again what I said: His program isn't multithreaded. If you use threads, then you can NOT acces any GUI item - such as a TMemo - from your thread. VCL is not "thread safe". > I was told by a friend that the reason for that happening is that window is not an RT OS and will time slice the operation. This is not related at all to a real time operating system or not. > Am I missing here something ? I don't know. Maybe you forgot that TWSocket component multitask without using threads. It simply uses events. And as such don't need to use synchronization objects. Of course if you use TWSocket in a thread, you are back to the difficulties of multithreading. And you may actually built a slower application to make a long story short. -- 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 This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses. -- 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] When receiving UDP datas, find if there were sent through a broadcast
Angus, you can either arrange the clients tell you as part of the data you send seems to be the simplest solution but needs to change the client software. use a different port for broadcasts also needs to change the client software. keep track of the IP addresses locally in action already. I don't believe there is anything in the IP protocol that will identify a broadcast If not, is there a flag somewhere in twsocket to tell an UDP socket to ignore clients who knocks on a given port with a 255.255.255.255 address ? Lionel -- 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