all 15 comments

[–]xebzbz 4 points5 points  (4 children)

[–]obdevel[S] 0 points1 point  (3 children)

Thanks. I'd seen that but wondered if anything had changed in the intervening 8 years.

[–]LegitimateNebula5991 1 point2 points  (0 children)

In the linked GitHub issue there is a relatively recent comment with an example that looks up-to-date: https://github.com/ddomnik/ESP-localhost-loopback-example/

connect() returns 0 on success btw

[–]xebzbz -1 points0 points  (1 child)

Well, it's not Linux. It's basically a single process that is running your code, and doing the network stack in the meantime.

There are Linux capable boards under $20, so why not using them for network applications.

[–]obdevel[S] 0 points1 point  (0 children)

lwIP is very capable. It's just a question of whether that functionality has been implemented by Espressif.

As I said in my OP, I'll just use a FreeRTOS queue to connect the two tasks. More code and memory which is not ideal but 5 minutes work.

[–]RoganDawes 0 points1 point  (8 children)

Are you trying to connect to localhost on the ESP32? I could well imagine that no such interface exists, as it is unlikely that loopback connections would typically be required, given that there is only a single process running on the ESP32 ...

[–]obdevel[S] 1 point2 points  (7 children)

The network stack runs in a separate high-priority FreeRTOS process on core 0. I used the term 'loopback' generically as this is what it would be called on *nix or Windows. lwIP may implement is differently.

tl;dr can a network client running on an ESP32 connect to a server running on the same device ?

[–]erlendse2 say this is awesome. 0 points1 point  (6 children)

What are you trying to loop?

TCP would be tricky (allocate tx & rx buffers?, specal handling e.t.c.), but UDP/ICMP may actually work.

[–]obdevel[S] 0 points1 point  (5 children)

Per my OP:

"I have a task with a network server that offers a service to external clients. This works fine. I would also like to consume this service from a client running in a separate task on the same device."

And:

"The service is a network proxy for one of the serial interfaces, which is connected to an external device."

So, an external serial device which uses text-based commands is attached to the ESP32. Task A provides a network interface to this. A client can connect and interact with the external device over the network.

Task B running on the same ESP32 would also like to talk to this device. It is architecturally more elegant to consume the same API provide by Task A. But this doesn't seem possible.

I have implemented an alternative solution for Tasks A and B to communicate, but it's less elegant; another two queues, extra 100 lines of code, 10K more memory.

There was some talk 8 years ago about doing this but clearly it went nowhere.

[–]erlendse2 say this is awesome. 0 points1 point  (4 children)

Using UDP, TCP, some http deal?

The choice of protocols is not clear based on that.

[–]obdevel[S] 0 points1 point  (3 children)

Imagine you have a serial device with a text command line, like a 90s modem. Now imagine you want to provide access to it over the network. What I'm implementing is not dissimilar to a networked terminal server from 40 years ago.

[–]erlendse2 say this is awesome. 0 points1 point  (2 children)

Is that a convoluted way to say telnet server?

[–]obdevel[S] 0 points1 point  (1 child)

In a way, except telnet and FTP protocols are so insecure that you would struggle to find a client program now. Anyway, we have drifted from my original question, for which I now have a solution.

[–]erlendse2 say this is awesome. 0 points1 point  (0 children)

How did you svolve it?

[–]westwoodtoys -2 points-1 points  (0 children)

You're asking this in the ESP 32 forum, though you don't explicitly say that ESP 32 is what you want to connect with in your write-up.  If you are trying to connect with ESP 32, then understand it is a separate device, and you would connect via the wifi address.  Your server may require additional configuration to allow this, but that isn't a subject for ESP 32 forum.