Skip to content
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

chapter 4: getaddrinfo() and destination IP of packet #17

Open
ghenry opened this issue Nov 25, 2021 · 2 comments
Open

chapter 4: getaddrinfo() and destination IP of packet #17

ghenry opened this issue Nov 25, 2021 · 2 comments

Comments

@ghenry
Copy link

ghenry commented Nov 25, 2021

Hi Lewis,

Have you ever done this with a UDP package?

https://stackoverflow.com/questions/5281409/get-destination-address-of-a-received-udp-packet

Looks like you can't use recvfrom and have to switch to recvmsg to use IP_PKTINFO

I'll dig into the book again.

Thanks for reading.

Gavin.

@codeplea
Copy link
Owner

Hi Gavin,

No, I haven't done it like that using only one socket before. What I have done, is opened a separate socket on each interface, and then the receiving address is determined by which socket it comes in on. Using multiple sockets will probably be more portable, but otherwise, the Stack Overflow solution might be simpler and I suspect would perform slightly better (no socket multiplexing).

@ghenry
Copy link
Author

ghenry commented Nov 25, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants