Changing socket remote address

Hi All,

I need your inputs on how to change the socket remote address.

Initially, when i create a datagram socket, it is bounded to local transport address and then remote address assigned. The socket is working and able send/receive data to the server.

After sometime, i need to change the remote address so that the application can communicate with different server. So i am clearing the previous assigned remote address by SIO_WSK_SET_REMOTE_ADDRESS as mentioned here.

https://docs.microsoft.com/en-us/windows-hardware/drivers/network/sio-wsk-set-remote-address

Then changing the socket remote address using the same SIO_WSK_SET_REMOTE_ADDRESS ioctl but specifying new IP address value. The IOCTL call was success, but for some reason the socket remote address was not changed and connection lost.

Any inputs on what i am doing wrong here?