Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Send Data To Tcp Client

Assistance Requested

Help GBot with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Product: (click to view product details)

EZ-Builder Controls: (click to view manual page)

GBot claims to have checked these sources:

Hello All,

I have successfully set up a TCP server in order to communicate with a Processing client running on the same computer as EZ-Builder. I am able to send data (variables) from Processing to EZ-Builder by simply using a myClient.send(blahblah) command. However, I cannot figure out how to send information to the Processing client from EZ-Builder. I have tried sendUDP("", 9000, "hello world"Winky 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 EZ-Builder is able to send information to this program, I just don't know how.

Am I missing something?


I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.

Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


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 EZ-Builder 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 EZ-Builder 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 EZ-Builder. 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 EZ-Builder that a TCP connection is established. In Processing, I get a readout of "EZ-Builder v2017.06.23.00 on TTY0 >" in the console. However, what i cannot do is send data from EZ-Builder 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 EZ-Builder program. I'm sorry that it isn't apparent to me, thus the question.


Definitely not slamming - pointing to directions Smile. 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 EZ-Builder to send it (at least not as TCP) but that your client can request it.

IE, sending EZ-Builder "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 Smile


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.