Open elham-Nikooie opened 1 month ago
Is there a reason you cannot use https://github.com/DoumanAsh/wpa-ctrl/blob/master/src/lib.rs#L634C45-L634C62 ?
Yes! I used that so far to receive the messages from wpa! But now I need a separate thread to just monitor unsolicited messages and act based on the received events! This thread should be able to monitor separately from the main thread that responding to regular commands like add_network!
For example I want to call add_network and do the entire job there including receiving the response to make sure everything is Ok! And at the same time in my other function I want to monitor_unsolicited_messages that can read the wpa file descriptor and extract the events!
I can't do that through the provided recv message! I can't read wpa_controller by recv function from multi threads and receive the message on both!
I guess I should refactor it not to use internal buffer or make it optional to enable it to be thread safe There is no need for raw file descriptor as it is badly usable for regular user
Or maybe just provide another function like monitor_unsolicited_messages()
to return those in a separate channel then user doesn't need to have access to self.socket.as_raw_fd()!
.
I only need a way to read those WPA Events separately if you can come up with another function fro that, would be great!
There is slight problem wit that approach is that you cannot really control order of messages so having multiple readers might be problematic In any case I will need to think on that
I created prototype interface to have separate instances with and without buffer https://github.com/DoumanAsh/wpa-ctrl/pull/5
For your purposes non-buffered interface should suffice, but you'd need to take care of providing buffer yourself
I need to read messages from the file descriptor of wpa_controller in a separate thread to check events from unsolicited messages! For doing that I think you should add this:
Then I can start reading
recvfrom(fd, &mut buffer)
from it by:let fd = wpa_controller.as_raw_fd();