-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass socket to handler callback #6
Comments
Hey @ptxmac, could you provide an example of why the SocketAddr would be useful? Just trying to understand the use case. |
Yes, I'm currently investigating rust as a basic for a LWM2M implementation. In the LWM2M protocol the client sends a single message to the server, and then switches from being a coap client to a coap server. The lwm2m server is then expected to send requests back to the client through the address/port the lwm2m client first connected through. |
Interesting. Do you just need the Right now the |
Having a context would also be useful, but in my case I need the |
Do you need the server's port to be the same on your second connection? e.g.
If so, you will need to completely stop the CoAP server when the request is made, because you cannot share port 5683 on Machine_B (not a rust specific thing). I was already thinking about changing the hander signature from
Would this work for you? |
When the lwm2m server is talking back to the client it will chose a new random port, so that's not a issue. I like that signature, it looks like it would be perfect for my needs |
@Covertness any complaints with this new signature? I think this would also prevent thrashing of this signature (I've already changed it a couple times) This will also make it easier to include a "context" handle of some sort for requests. |
@ptxmac Started work on this. Feel free to follow along: https://github.com/jamesmunns/coap-rs/tree/packet-refactor No address in the request yet, but I have the |
@jamesmunns Agreed. Object-oriented make the code more flexible. |
@ptxmac will be merging soon. Please let me know if you have any concerns |
Yes, that suits my needs I think. My experiments are just starting, so I might find more needs later. But having the |
For some applications it's necessary to have access to the sender from the callback. It would be useful to have the
SocketAddr
in the handler signature.The text was updated successfully, but these errors were encountered: