I’m using the POCO c++ libraries, and I’m at a loss. Is there any way to set the source port when sending a UDP datagram? It looks like it’s always set to the destination port, but surely this is possible.
My code looks something like this:
Poco::Net::SocketAddress bcast("255.255.255.255", m_txPort);
DatagramSocket dgs = DatagramSocket(bcast,false);
dgs.setBroadcast(true);
dgs.sendTo(data,dataLength, broad);
Failing that, I might be switching to Boost – I assume boost can do this, right?
Should work just fine; you pass a SocketAddress with the source address and port into your
DatagramSocketconstructor which says which local address to bind to; following your example;Then you pass a separate socketaddress with the destination address and port into
SendTo.