[asio-users] R: Use of UDP socket
Brought to you by:
chris_kohlhoff
|
From: Gatti G. <Gia...@fi...> - 2026-06-23 13:02:08
|
I found the solution for the first question: just to call explicitly desctructors and constructors of endpoint and socket, like for the pointers. Probably this "special" methods do something more than calling individually the various methods. Gianluca ________________________________ Da: Gatti Gianluca <Gia...@fi...> Inviato: martedì 23 giugno 2026 14:17 A: asi...@li... <asi...@li...> Oggetto: Use of UDP socket Hello, I have two questions on the use of the UDP socket. The first one: how can I close and restart a connection on a different port? I tried to call the cancel, close and shutdown methods and then call the connect method, but on this method an exception is thrown. A solution I found is to use the socket as a pointer and, consequently, delete it when I want to close the connection and call the constructor with the new parameters. I think that this is a workaround, but it should be possible to do it without the use of a pointer. The second one: the socket constructor and the asynch_receive_from method need an endpoint as a parameter. Why? I think it is redundant, only on the socket constructor is needed. Thank you so much in advance for the suggestions, Gianluca |