"Kevin P. Fleming" <[email protected]> writes: > I've just looked into this a bit, and I don't see how using connect() > would actually solve the problem. If we receive a UDP datagram from a > SIP endpoint, we could use socket() and connect() to create a socket > specifically for sending to (and receiving from) that endpoint in the > future, but we can't specify the source address to be used by that > socket. The only way I know of to specify the source address for > outbound packets is to use a raw socket and compose the IP header > ourselves, which would be overkill.
You just bind() to the source address you want to use for outgoing packets. I have just tested it, it works here at least. The tricky bit is knowing which source address you want to use. That you can get from IP_PKTINFO, somewhat portably. Once you have a socket with connect() and bind(), the full 5-tuplet of protocol, srcaddr, srcport, dstaddr, dstport is defined, and all further traffic related to that "connection" should be going to that socket. However, in between the time that the first packet arrived and that socket is up and running, more packets may have been queued on the original server socket. This cannot happen with TCP because accept() is atomic (the client cannot send more data before the three-way-handshake is done), but there is no such luck with UDP. /Benny -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
