Asked — Edited
Resolved Resolved by DJ Sures!

Send Data To Tcp Client

Hello All,

I have successfully set up a TCP server in order to communicate with a Processing client running on the same computer as ARC. I am able to send data (variables) from Processing to ARC by simply using a myClient.send(blahblah) command. However, I cannot figure out how to send information to the Processing client from ARC. I have tried sendUDP("", 9000, "hello world") etc, with no luck.

By the way, when I use myClient.readString() and print it to the terminal in Processing, I see:

EZ-Builder v2017.06.23.00 on TTY0 >

So I know that ARC is able to send information to this program, I just don't know how.

Am I missing something?



Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.


Is your server set up to listen to UDP or just TCP? The SendUDP command is sending UDP not TCP packets.

I don't believe ARC currently has a SendTCP command, I suspect because there is typically more negotiation required for TCP client/server communications than just a send or receive of one message at a time. There is a GETUrl command if you set up a web service for receiving commands, or it would be fairly straightforward to write a plugin specific to your particular TCP Server.



You may also want to look at the MQTT client and broker plugins. Great for passing variables back and forth between ARC and other applications because it will queue messages until they are read, so doesn't need to be synchronous.



You need to learn what TCP is. You can't simply "send tcp". It's not like udp. It's a different protocol that works different.

TCP is stateless. Requires an actual negotiated connection. Udp does not.

What are you trying to do? Just use the tcp server. You can query variables or anything you want. Have you not looked at the tutorial page for the connection control? The question mark tells all.

In the tcp server, you csn "print $variable" even...


Thanks Alan, I will take a look into those.

DJ, yes I have read the connection control tutorial. I spent a good deal of time looking into this before asking my question. its not fun to be slammed for asking a question tho.

As I said, i have set up the server. I have been able to pass variables from my client program to ARC. What i cannot do is send data to the client.

Here is a simple script in processing that demonstrates what I want to do:

Client myClient; 
String inString;

void setup() { 
  size (300, 100);
  myClient = new Client(this, "", 9000); 

void draw() { 
  if (myClient.available() > 0) { 
    inString = myClient.readString(); 

When I hit run on this sketch, I can see in ARC that a TCP connection is established. In Processing, I get a readout of "ARC v2017.06.23.00 on TTY0 >" in the console. However, what i cannot do is send data from ARC to the client and read it out in the console. I honestly don't know why you would tell me to learn TCP...I am quite familiar with it using telnet, putty, etc. My question is how do I write info to a socket using your ARC program. I'm sorry that it isn't apparent to me, thus the question.


Definitely not slamming - pointing to directions:). As for tcp, it's a connection that requires a state. So you cannot write to the server or client without a connection. For example, if you were to telnet into a server, the connection isn't "written to" by any programs. The client submits data, which are interpreted as commands.

Your client can send commands and the data is returned, like telnet.

As my example states, if you send "print $variable" to the server from client, the $variable data will be returned.

Tcp is not like udp. You cannot simply send data to an IP address without negotiated connection. The sendudp() command can't be applied to tcp. Udp doesn't require a connection.

Tcp requires a stateful connection. I suggest reading a tad about tcp to understand how you can do what you're attempting to do.

If you tell me what data you'd like to return to your client, I can provide an example command to send


What DJ was saying is that you don't tell ARC to send it (at least not as TCP) but that your client can request it.

IE, sending ARC "print $variable" it will respond with the contents of $variable, because your TCP client has established hte socket and is holding it open. But EZ-Script would not know about that socket, so it can't send to it.

To send from an EZ-Script, you need to listen for UDP, not TCP packets (since UDP doesn't require a pre-negotiated socket connection), and then use the SendUDP command. Or, since you seem ot have some programming ability, you could write a TCP client plugin that can establish and maintain the tcp socket connection to your TCP server and send it script commands. Interacting with a plugin would typically be done with the ControlCommand script statement).



I think the easiest way to do what you're wanting to do is tell me and I'll give you an example:)


Whoops, looks like DJ and I hit enter at the same time.

Follow his advice of providing more details on your goal. I tend to overthink solutions and DJ may have a simpler way of doing it.



Thanks, got it sorted out.

My issue was that when the client asked for data via print(variable) etc, I needed to strip the trailing carriage return before it became usable.


Ah yeah! Good call.

If you'd like, there is a plugin system as well. You can create a quick plugin that can communicate with your Processing project. Let me know how I can help