The Boost ASIO library provides a port()
get/set method for a socket local_endpoint
, but when I try to switch to a different port while the work queue is running, calling socket.local_endpoint().port(1234)
call does not change the port. Does anyone have experience with this?
Based on an option received over TFTP, I need to switch the port over which the server and client are communicating.
To answer why
socket.local_endpoint().port(1234) call does not change the port.
as far as I know, the basic_socket
class *_endpoint()
implementations return a copy of endpoint_type
object, not a reference, so the change you are trying to make, won't affect the socket
object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.