Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] Setting UDP Source Port
From: Simply Seven (simply7_at_[hidden])
Date: 2009-04-03 01:03:37


On Apr 2, 2009, at 9:22 PM, Scott McMurray wrote:

> I'm writing an application that makes use of the source port in the
> UDP header. The only way I've found that sets it is by setting the
> endpoint on construction of the udp::socket. The problem with that,
> however, is that I have 3 different components that want to use that
> port, one listening and two sending. Understandably, I cannot bind
> the same port for all three. (Incidentally, while binding with the
> udp::socket constructor works, the bind call gives a bad file
> descriptor exception. I'm using 1.35, though, so that may have been
> fixed.)
>
> Is there some way to set the source port without binding? Since
> there's no session state, it seems like I should be able to send
> packets from any number of sockets. (I can't just share a socket, as
> they're not shared-objects thread-safe, according to the
> documentation.)

I think your only option here is to multiplex all over a single socket
because your describing a UDP transponder/multiplexor if I am reading
correctly and that is how they operate at the application level.
Another problem here is that if you place a NAT between these hosts
then the UDP src port will be mapped(by NAT device) to a sequenced
port, thus the other end will see the wrong port. STUN takes care of
this last part to get the reflexive/srv addr for you to insert into
headers using an XOR. If this is a LAN protocol then you can forget
the last part.

-s7

> Thanks,
> ~ Scott McMurray
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net