// Bind implements tcpip.Endpoint.Bind.
Bind implements tcpip.Endpoint.Bind.
// Bind implements tcpip . Endpoint . Bind .
func (e *endpoint) Bind(addr tcpip.FullAddress) tcpip.Error {
	e.mu.Lock()
	defer e.mu.Unlock()
	if len(addr.Addr) != 0 && e.stack.CheckLocalAddress(e.RegisterNICID, e.NetProto, addr.Addr) == 0 {
		return &tcpip.ErrBadLocalAddress{}
	}
	if e.associated {
		if err := e.stack.RegisterRawTransportEndpoint(e.NetProto, e.TransProto, e); err != nil {
			return err
		}
		e.stack.UnregisterRawTransportEndpoint(e.NetProto, e.TransProto, e)
		e.RegisterNICID = addr.NIC
		e.BindNICID = addr.NIC
	}
	e.BindAddr = addr.Addr
	e.bound = true
	return nil
}
func ( e * endpoint ) Bind ( addr tcpip . FullAddress ) tcpip . Error { e . mu . Lock ( ) defer e . mu . Unlock ( ) if len ( addr . Addr ) != 0 && e . stack . CheckLocalAddress ( e . RegisterNICID , e . NetProto , addr . Addr ) == 0 { return & tcpip . ErrBadLocalAddress { } } if e . associated { if err := e . stack . RegisterRawTransportEndpoint ( e . NetProto , e . TransProto , e ) ; err != nil { return err } e . stack . UnregisterRawTransportEndpoint ( e . NetProto , e . TransProto , e ) e . RegisterNICID = addr . NIC e . BindNICID = addr . NIC } e . BindAddr = addr . Addr e . bound = true return nil }
Bind implements tcpip.Endpoint.Bind.
Bind implements tcpip . Endpoint . Bind .
// If a local address was specified, verify that it's valid. // Re-register the endpoint with the appropriate NIC.