pub fn bind<T: Into<Endpoint>>(&mut self, endpoint: T) -> Result<()> {
        let endpoint = endpoint.into();
        if !endpoint.is_specified() {
            return Err(Error::Unaddressable);
        }

        if self.is_open() { return Err(Error::Illegal) }

        self.endpoint = endpoint;
        Ok(())
    }
/// Bind the socket to the given endpoint.
///
/// This function returns `Err(Error::Illegal)` if the socket was open
/// (see [is_open](#method.is_open)), and `Err(Error::Unaddressable)`
/// if `endpoint` is unspecified (see [is_specified]).
///
/// # Examples
///
/// ## Bind to ICMP Error messages associated with a specific UDP port:
///
/// To [recv] ICMP error messages that are associated with a specific local
/// UDP port, the socket may be bound to a given port using [IcmpEndpoint::Udp].
/// This may be useful for applications using UDP attempting to detect and/or
/// diagnose connection problems.
///
/// ```
/// # use smoltcp::socket::{Socket, IcmpSocket, IcmpPacketBuffer, IcmpSocketBuffer};
/// # let rx_buffer = IcmpSocketBuffer::new(vec![IcmpPacketBuffer::new(vec![0; 20])]);
/// # let tx_buffer = IcmpSocketBuffer::new(vec![IcmpPacketBuffer::new(vec![0; 20])]);
/// use smoltcp::wire::IpEndpoint;
/// use smoltcp::socket::IcmpEndpoint;
///
/// let mut icmp_socket = // ...
/// # match IcmpSocket::new(rx_buffer, tx_buffer) {
/// #     Socket::Icmp(socket) => socket,
/// #     _ => unreachable!()
/// # };
///
/// // Bind to ICMP error responses for UDP packets sent from port 53.
/// let endpoint = IpEndpoint::from(53);
/// icmp_socket.bind(IcmpEndpoint::Udp(endpoint)).unwrap();
/// ```
///
/// ## Bind to a specific ICMP identifier:
///
/// To [send] and [recv] ICMP packets that are not associated with a specific UDP
/// port, the socket may be bound to a specific ICMP identifier using
/// [IcmpEndpoint::Ident]. This is useful for sending and receiving Echo Request/Reply
/// messages.
///
/// ```
/// # use smoltcp::socket::{Socket, IcmpSocket, IcmpPacketBuffer, IcmpSocketBuffer};
/// # let rx_buffer = IcmpSocketBuffer::new(vec![IcmpPacketBuffer::new(vec![0; 20])]);
/// # let tx_buffer = IcmpSocketBuffer::new(vec![IcmpPacketBuffer::new(vec![0; 20])]);
/// use smoltcp::socket::IcmpEndpoint;
///
/// let mut icmp_socket = // ...
/// # match IcmpSocket::new(rx_buffer, tx_buffer) {
/// #     Socket::Icmp(socket) => socket,
/// #     _ => unreachable!()
/// # };
///
/// // Bind to ICMP messages with the ICMP identifier 0x1234
/// icmp_socket.bind(IcmpEndpoint::Ident(0x1234)).unwrap();
/// ```
///
/// [is_specified]: enum.IcmpEndpoint.html#method.is_specified
/// [IcmpEndpoint::Ident]: enum.IcmpEndpoint.html#variant.Ident
/// [IcmpEndpoint::Udp]: enum.IcmpEndpoint.html#variant.Udp
/// [send]: #method.send
/// [recv]: #method.recv
Bind the socket to the given endpoint.
Bind the socket to the given endpoint .
pub fn bind<T: Into<Endpoint>>(&mut self, endpoint: T) -> Result<()> {
        let endpoint = endpoint.into();
        if !endpoint.is_specified() {
            return Err(Error::Unaddressable);
        }
        if self.is_open() { return Err(Error::Illegal) }
        self.endpoint = endpoint;
        Ok(())
    }
pub fn bind < T : Into < Endpoint > > ( & mut self , endpoint : T ) -> Result < ( ) > { let endpoint = endpoint . into ( ) ; if ! endpoint . is_specified ( ) { return Err ( Error :: Unaddressable ) ; } if self . is_open ( ) { return Err ( Error :: Illegal ) } self . endpoint = endpoint ; Ok ( ( ) ) }
Bind the socket to the given endpoint.
Bind the socket to the given endpoint .
&mut self
endpoint
T
&mut self
endpoint
T
examples
None
bind to icmp error messages associated with a specific udp port:
To [recv] ICMP error messages that are associated with a specific local
UDP port, the socket may be bound to a given port using [IcmpEndpoint::Udp].
This may be useful for applications using UDP attempting to detect and/or
diagnose connection problems.


To [ recv ] ICMP error messages that are associated with a specific local UDP port the socket may be bound to a given port using [ IcmpEndpoint :: Udp ] . This may be useful for applications using UDP attempting to detect and / or diagnose connection problems .
use smoltcp::socket::{socket, icmpsocket, icmppacketbuffer, icmpsocketbuffer};
None
let rx_buffer = icmpsocketbuffer::new(vec![icmppacketbuffer::new(vec![0; 20])]);
None
let tx_buffer = icmpsocketbuffer::new(vec![icmppacketbuffer::new(vec![0; 20])]);
use smoltcp::wire::IpEndpoint;
use smoltcp::socket::IcmpEndpoint.

let mut icmp_socket =
use smoltcp :: wire :: IpEndpoint ; use smoltcp :: socket :: IcmpEndpoint . let mut icmp_socket =
match icmpsocket::new(rx_buffer, tx_buffer) {
None
socket::icmp(socket) => socket,
None
_ => unreachable!()
None
};
Bind to ICMP error responses for UDP packets sent from port 53.
let endpoint = IpEndpoint::from(53);
icmp_socket.bind(IcmpEndpoint::Udp(endpoint)).unwrap();
```
Bind to ICMP error responses for UDP packets sent from port 53 . let endpoint = IpEndpoint :: from ( 53 ) ; icmp_socket . bind ( IcmpEndpoint :: Udp ( endpoint )) . unwrap () ; ` ` `
bind to a specific icmp identifier:
To [send] and [recv] ICMP packets that are not associated with a specific UDP
port, the socket may be bound to a specific ICMP identifier using
[IcmpEndpoint::Ident]. This is useful for sending and receiving Echo Request/Reply
messages.


To [ send ] and [ recv ] ICMP packets that are not associated with a specific UDP port the socket may be bound to a specific ICMP identifier using [ IcmpEndpoint :: Ident ] . This is useful for sending and receiving Echo Request / Reply messages .
use smoltcp::socket::{socket, icmpsocket, icmppacketbuffer, icmpsocketbuffer};
None
let rx_buffer = icmpsocketbuffer::new(vec![icmppacketbuffer::new(vec![0; 20])]);
None
let tx_buffer = icmpsocketbuffer::new(vec![icmppacketbuffer::new(vec![0; 20])]);
use smoltcp::socket::IcmpEndpoint.

let mut icmp_socket =
use smoltcp :: socket :: IcmpEndpoint . let mut icmp_socket =
match icmpsocket::new(rx_buffer, tx_buffer) {
None
socket::icmp(socket) => socket,
None
_ => unreachable!()
None
};
Bind to ICMP messages with the ICMP identifier 0x1234
icmp_socket.bind(IcmpEndpoint::Ident(0x1234)).unwrap();
```

[is_specified]: enum.IcmpEndpoint.html#method.is_specified
[IcmpEndpoint::Ident]: enum.IcmpEndpoint.html#variant.Ident
[IcmpEndpoint::Udp]: enum.IcmpEndpoint.html#variant.Udp
[send]: #method.send
[recv]: #method.recv
Bind to ICMP messages with the ICMP identifier 0x1234 icmp_socket . bind ( IcmpEndpoint :: Ident ( 0x1234 )) . unwrap () ; ` ` ` [ is_specified ] : enum . IcmpEndpoint . html#method . is_specified [ IcmpEndpoint :: Ident ] : enum . IcmpEndpoint . html#variant . Ident [ IcmpEndpoint :: Udp ] : enum . IcmpEndpoint . html#variant . Udp [ send ] : #method . send [ recv ] : #method . recv