Kpotmake Posted October 26, 2021 Report Share Posted October 26, 2021 I have made a program for a Unitronics PLC to communicate with another PLC (sigmatek) over TCP. Unitronics is the server, the sigmatek PLC is the client. I am sending a big data table over TCP (5120 bytes in total). The way it works is Sigmatek initiates a connection as a client, and unitronics sends the data once a connection is established. I have it working, but I'm not statisfied with the way it is programmed now. Let me try to explain my problem: For some reason I cannot send more then 1024 bytes with one TCP server TX function block, so I have split the data up in 5 seperate buffers, that I send to 5 clients. (I have configured 5 clients in the other PLC), these 5 clients all connect to the same server. This is no problem for me. The problem is, that to send the buffer to the correct client, I need to know the client ID. What I'm doing right now to figure the client ID number out is: In the sigmatek PLC I have made a program that the first client has to connect, and when the first client is connected, connect the second one after a small delay, and so on.. In my Unitronics PLC, if a new Client is connecting, I can check the ID of that client by checking the connection array (it's an array of 16 bits). For example: Sigmatek tries to connect the first client, if the connection is esablished, then bit 4 of my connection array in Unitronics might become high, now I know Client 1 has ID 4, when the second client connects, bit 2 might turn on, so the second client has ID 2, and so on.. and when a connection is lost, I disconnect them all and start the process again This works fine, but is far from elegant... What's the proper way to find out the client ID on the server side of a TCP server / client model? Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.