fn udp_bind(&mut self, sn: Sn, port: u16) -> Result<(), Self::Error> {
        debug_assert!(
            port_is_unique(self, sn, port)?,
            "Local port {port} is in use"
        );

        self.set_sn_cr(sn, SocketCommand::Close)?;
        // This will not hang, the socket status will always change to closed
        // after a close command.
        // (unless you do somthing silly like holding the W5500 in reset)
        while self.sn_sr(sn)? != Ok(SocketStatus::Closed) {}
        self.set_sn_port(sn, port)?;
        const MODE: SocketMode = SocketMode::DEFAULT.set_protocol(Protocol::Udp);
        self.set_sn_mr(sn, MODE)?;
        self.set_sn_cr(sn, SocketCommand::Open)?;
        // This will not hang, the socket status will always change to Udp
        // after a open command with SN_MR set to UDP.
        // (unless you do somthing silly like holding the W5500 in reset)
        while self.sn_sr(sn)? != Ok(SocketStatus::Udp) {}
        Ok(())
    }
/// Binds the socket to the given port.
///
/// This will close the socket, which will reset the RX and TX buffers.
///
/// # Comparison to [`std::net::UdpSocket::bind`]
///
/// This method accepts a port instead of a [`net::SocketAddrV4`], this is
/// because the IP address is global for the device, set by the
/// [source IP register], and cannot be set on a per-socket basis.
///
/// Additionally you can only provide one port, instead of iterable
/// addresses to bind.
///
/// # Panics
///
/// * (debug) The port must not be in use by any other socket on the W5500.
///
/// # Example
///
/// Bind the first socket to port 8080.
///
/// ```no_run
/// # use embedded_hal_mock as h;
/// # let mut w5500 = w5500_ll::blocking::vdm::W5500::new(h::spi::Mock::new(&[]), h::pin::Mock::new(&[]));
/// use w5500_hl::ll::{Registers, Sn::Sn0};
/// use w5500_hl::Udp;
///
/// w5500.udp_bind(Sn0, 8080)?;
/// # Ok::<(), w5500_hl::ll::blocking::vdm::Error<_, _>>(())
/// ```
///
/// [`net::SocketAddrV4`]: [crate::net::SocketAddrV4]
/// [`std::net::UdpSocket::bind`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.bind
/// [source IP register]: w5500_ll::Registers::sipr
Binds the socket to the given port.
This will close the socket, which will reset the RX and TX buffers.
Binds the socket to the given port . This will close the socket which will reset the RX and TX buffers .
fn udp_bind(&mut self, sn: Sn, port: u16) -> Result<(), Self::Error> {
        debug_assert!(
            port_is_unique(self, sn, port)?,
            "Local port {port} is in use"
        );
        self.set_sn_cr(sn, SocketCommand::Close)?;
        // This will not hang, the socket status will always change to closed
        // after a close command.
        // (unless you do somthing silly like holding the W5500 in reset)
        while self.sn_sr(sn)? != Ok(SocketStatus::Closed) {}
        self.set_sn_port(sn, port)?;
        const MODE: SocketMode = SocketMode::DEFAULT.set_protocol(Protocol::Udp);
        self.set_sn_mr(sn, MODE)?;
        self.set_sn_cr(sn, SocketCommand::Open)?;
        // This will not hang, the socket status will always change to Udp
        // after a open command with SN_MR set to UDP.
        // (unless you do somthing silly like holding the W5500 in reset)
        while self.sn_sr(sn)? != Ok(SocketStatus::Udp) {}
        Ok(())
    }
fn udp_bind ( & mut self , sn : Sn , port : u16 ) -> Result < ( ) , Self :: Error > { debug_assert ! ( port_is_unique ( self sn port ) " " ) ; self . set_sn_cr ( sn , SocketCommand :: Close ) ? ; // This will not hang, the socket status will always change to closed // after a close command. // (unless you do somthing silly like holding the W5500 in reset) while self . sn_sr ( sn ) ? != Ok ( SocketStatus :: Closed ) { } self . set_sn_port ( sn , port ) ? ; const MODE : SocketMode = SocketMode :: DEFAULT . set_protocol ( Protocol :: Udp ) ; self . set_sn_mr ( sn , MODE ) ? ; self . set_sn_cr ( sn , SocketCommand :: Open ) ? ; // This will not hang, the socket status will always change to Udp // after a open command with SN_MR set to UDP. // (unless you do somthing silly like holding the W5500 in reset) while self . sn_sr ( sn ) ? != Ok ( SocketStatus :: Udp ) { } Ok ( ( ) ) }
Binds the socket to the given port.
Binds the socket to the given port .
&mut self
sn
Sn
port
u16
&mut self
sn
Sn
port
u16
comparison to [`std::net::udpsocket::bind`]
This method accepts a port instead of a [`net::SocketAddrV4`], this is
because the IP address is global for the device, set by the
[source IP register], and cannot be set on a per-socket basis.

Additionally you can only provide one port, instead of iterable
addresses to bind.
This method accepts a port instead of a [ ` net :: SocketAddrV4 ` ] this is because the IP address is global for the device set by the [ source IP register ] and cannot be set on a per - socket basis . Additionally you can only provide one port instead of iterable addresses to bind .
panics
(debug) The port must not be in use by any other socket on the W5500.
( debug ) The port must not be in use by any other socket on the W5500 .
example
Bind the first socket to port 8080.


Bind the first socket to port 8080 .
use embedded_hal_mock as h;
None
let mut w5500 = w5500_ll::blocking::vdm::w5500::new(h::spi::mock::new(&[]), h::pin::mock::new(&[]));
None
ok::<(), w5500_hl::ll::blocking::vdm::error<_, _>>(())
None