Re: Problem with a UDP server implements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux