I have configured a control interface for hostapd on embedded Linux like this in the configuration file:
ctrl_interface=/var/run/hostapd
I can see that a file is created in the file system:
ls -la /var/run/hostapd/wifi_ap0
srwxrwx--- 1 root root 0 Jul 17 20:40 /var/run/hostapd/wifi_ap0
However when I try to open a connection to this interface via wpa_ctrl_open("/var/run/hostapd/wifi_ap0") it returns NULL and strerror(errno) returns No such file or directory.
Clearly the file exists, so I don't understand what is wrong here. Any hints?
Try
-a start as daemon and -r try to reconnect to hostapd socket.
I had same problem and it was sufficient to add -r Because I start hostapd_cli as service to open a Fotinet vpn every time the client is connected.