Chat freely about anything...

User avatar
By Masoud Navidi
#87724 hi everyone.

I have an ESP8266 and android phone which are connected to my wifi-network, separately. I want to transfer data between my android phone and ESP8266 over that wifi network (not using a broker nor using ESP8266 in AP-mode). I want my wifi-network to transfer data for me. Can I do that?
if yes, how can I do that and what do I need?

P.S. I'm new to Arduino and ESP8266 but till now I have used my ESP in AP and STA mode perfectly and I don't have any problem with them.
User avatar
By JurajA
#87748 you can use TCP sockets communication. esp8266 arduino can be a server or a client.

WiFiClient object wraps a TCP socket. A normal TCP socket is connected to IP address and port.

WiFiServer starts a listening socket on a port. If server on listening socket is contacted by a remote client socket, it creates a local socket connected with the remote client socket on a free port and returns a WiFiClient object wrapping the socket. Everything you write or print to a WiFiClient is send to that one remote socket.

If one of a client socket connects it to IP address and port of the server, then you get there a socket there and this two sockets are connected. What you write/print on one side, you read on the other side.

client socket

if (client.connect(serverIP, PORT)) {
String response = client.readStringUntil('\n');

server side

WiFiClient client = server.available();
if (client && client.connected()) {
String request = client.readStringUntil('\n');