WIZnet Developer Forum

W5500 Rules for changing UDP port numbers?

I have configured a socket for UDP operation. Everthing works ok. I would like to change the destination & source port numbers between operations (RX/TX). Do I have to close and then re-open the socket to do this?

For TX, I should be able to change the socket without having to close/re-open. This makes sense.

For RX, maybe not, as data could be arriving just when the change occurs.

Can someone please clarify this for me?

Thanks.

Hi,
configurations are TX ie “client mode” or RX ie “server mode”.
In both cases, you should start from the condition of closed socket just because the buffer pointers must start from this condition.
In client mode performs a transmission to another peer and define your own output port, peer IP address and the receiving port.
In server mode you define your receiving port and the package that you receive in the first bytes contain the IP address of the peer and his receiving port.
I understand you want a server “active” once received a package change its port as it happens in some protocols like the remote run command (RPC) where the server uses a default port for receiving new client and then use a different port to establish flow data.
I think the easiest way is to use a second socket that it opens to the peer of a new random port … however the protocol must make from scratch because I have not seen such examples.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.