Re: [asio-users] Use of UDP socket
Brought to you by:
chris_kohlhoff
|
From: klewwqeouhuih <cig...@gm...> - 2026-07-20 23:53:51
|
Hi, As for your first question, you need to call those methods in the following sequence: cancel(), shutdown(), close() - this way a socket is properly closed and you can use connect on it. You may have gotten exceptions when calling connect() after shutdown() because shutdown() does not clear information about sockets in the underlying services. As for your second question, constructor does not necessarily need an endpoint, but you may choose to give it to the constructor, therefore the socket will be opened already bound to that endpoint, so you don't have to call open(), connect(). Speaking of async_receive_from, it needs an endpoint in the arguments because remote sender's address will be written into this endpoint. |