All of lore.kernel.org
 help / color / mirror / Atom feed
From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Problem with a UDP server implements
Date: Sat, 15 Oct 2011 08:04:44 +0200	[thread overview]
Message-ID: <20111015060444.GA2282@grml> (raw)
In-Reply-To: <201110150151405785431@gmail.com>

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

  reply	other threads:[~2011-10-15  6:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14 17:51 Problem with a UDP server implements jiangtao.jit
2011-10-15  6:04 ` michi1 at michaelblizek.twilightparadox.com [this message]
2011-10-15  8:29   ` tao jiang
2011-10-15  9:01     ` michi1 at michaelblizek.twilightparadox.com
2011-10-15  9:50       ` tao jiang
2011-10-15 11:58 ` Bernd Petrovitsch
2011-10-17 23:26   ` tao jiang
2011-10-18  9:20     ` Bernd Petrovitsch
2011-10-18 14:48       ` tao jiang
2011-10-19  7:28         ` Bernd Petrovitsch
2011-10-21 13:07           ` tao jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111015060444.GA2282@grml \
    --to=michi1@michaelblizek.twilightparadox.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.