Simultaionus bidirectional TCP communication on ESP32 and ESP8266

Hello:

I am connecting one ESP32 and a few ESP8266 boards in a WiFi network, and I need bidirectional communication between the 32 and each of the 8266's.

I can find several examples on creating a client on the 32, and servers on the 8266's. I have only tried one pair so far, but it seems straight forward.

As I understand it, the client can only send data to the server.

However, I require the reverse as well. I need to send data from the client to the server, AND get a response back from the server. (I need to set a relay, and verify the relay got set before moving on to the next steps of the program.)

Must I set up a client and a server on both boards using different ports, or is there something I am missing to get a response from the server back to the client?

Thanks, Mark.

something like this you mean?

no.

At one point the "client = server.available();" on the server side would only return a client instance when the server received data from the client. That meant that the client had to be the first to send. After that, both sides can send in any order for as long as the TCP connection is open.

ESP-NOW. and some more words to make this post.

Hi Sherzaad:

I had not thought of making a "web server" on the server end and using the "get" mechanism, but I was hoping for a more simple approach. Thanks for the new link, I will keep it in my bookmarks as a reminder for future stuff.

Mark.

Hi Juraj:

I did not know this, it is exactly what I was looking for. Thanks.

One of the issues I have been having is the usage of the word "client". In most examples, on the client side, you make an instance called "client" with WiFiClient. Then I think you do the same on the server side, and most people call those instances the same thing. Then reading through it is very easy (for me) to get them mixed up.

Of course one can call those things anything one likes, but I find it confusing.

Mark.

Thanks, johnwasser:

I did not know this. It is very helpful.

Mark.

Thanks Idahowalker:

I did stumble across ESP-NOW, but I think it is a bit overkill and cumbersome.

I will go this route if all else fails for me.

Thanks, Mark.

normally they are called sockets

Perhaps the one on the client side should be called "meTheClient" and the one on the server side "theConnectedClient".

1 Like

I think OP needs to read up on sockets or UDP. They are about the simplest ways to communicate over a network connection.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.