Problem with a UDP server implements
michi1 at michaelblizek.twilightparadox.com
michi1 at michaelblizek.twilightparadox.com
Sat Oct 15 02:04:44 EDT 2011
Hi!
On 01:51 Sat 15 Oct , jiangtao.jit wrote:
> Hi:
>
> I'm writing a UDP server and meet a problem
> the UDP server program is run on a box with single card but has multi ip:
> like eth0 10.0.0.1
> eth0:1 10.0.0.2
> eth0:2 11.0.0.1
>
> I bind the server socket with INADDR_ANY
...
> when a client send a request to 10.0.0.1(eth0); the server use 10.0.0.1 to response
> and another client send a request to 10.0.0.2(eth0:1); the server use 10.0.0.2 to response
Well, is seems there is neither a variant of recvfrom() which tells you your
local address nor a variant of sendto() which allows you to specify your local
address. I guess you have to call getaddrinfo() and create a socket for every
address you want to bind to. If you want to stay single threaded you can
switch them to nonblocking and use epoll to wait for packets.
-Michi
--
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com
More information about the Kernelnewbies
mailing list