08-24-2012 09:23 AM - edited 08-24-2012 09:29 AM
@Ravishankar.nk wrote:
Pls change the RT application as TCP listen and GUI(Host) as TCP Open.
U didn't give the code. but i attached the basic module.
try it
This really doesn't matter. You can have either one be the client or server, it makes no fundemental difference. Also, ravishankars suggestion does not manager the header properly, or in a flexible way, by hardcoding a constant 4 bytes as the header. You should have a header cluster and use a type cast of the cluster to string and then get string length to determine the number of bytes to read from the TCP connection. This way if your cluster changes, you don't have to update a constant in your code. I'll draw up an example.
08-24-2012 09:40 AM - edited 08-24-2012 09:42 AM
I know this is a little OT but here's how I typically manage sending/receiving of data. I want to make sure you develop good habits Your clusters should be typedefs, I just didn't bother to convert them for this example. Note, this does not show how to manage open close connections, errors etc. But it shows how to transfer data in a flexible way. You never have to touch your TCP/IP communication now, just change the clusters and everything will update accordingly because you are getting the data size programmatically rather than using constants. Let me know if you have questions or don't see why this is flexible. Any even more flexible would be if you have different types of data you may send, in the action you say which type of data is being sent and then you can unflatten from string accordingly.
08-28-2012 04:59 AM
sure, it will reestablish.