socket-dynamic: Refactor setting source address when sending messages