Setting the source IP for a UDP socket

后端 未结 4 1206
攒了一身酷
攒了一身酷 2020-11-27 04:10

I have a UDP socket that is bound to INADDR_ANY to listen to packets on all the IPs my server has. I\'m sending out replies through the same socket.

Right now the se

4条回答
  •  醉话见心
    2020-11-27 04:52

    You either bind(2) to each interface address and manage multiple sockets, or let the kernel do the implicit source IP assignment with INADDR_ANY. There is no other way.

    My question would be - why do you need this? Is normal IP routing not working for you?

提交回复
热议问题