code: func sendReply(w io.Writer, resp uint8, addr *AddrSpec) error {
  	// Format the address
  	var addrType uint8
  	var addrBody []byte
  	var addrPort uint16
  	switch {
  	case addr == nil:
  		addrType = ipv4Address
  		addrBody = []byte{0, 0, 0, 0}
  		addrPort = 0
  
  	case addr.FQDN != "":
  		addrType = fqdnAddress
  		addrBody = append([]byte{byte(len(addr.FQDN))}, addr.FQDN...)
  		addrPort = uint16(addr.Port)
  
  	case addr.IP.To4() != nil:
  		addrType = ipv4Address
  		addrBody = []byte(addr.IP.To4())
  		addrPort = uint16(addr.Port)
  
  	case addr.IP.To16() != nil:
  		addrType = ipv6Address
  		addrBody = []byte(addr.IP.To16())
  		addrPort = uint16(addr.Port)
  
  	default:
  		return fmt.Errorf("Failed to format address: %v", addr)
  	}
  
  	// Format the message
  	msg := make([]byte, 6+len(addrBody))
  	msg[0] = socks5Version
  	msg[1] = resp
  	msg[2] = 0 // Reserved
  	msg[3] = addrType
  	copy(msg[4:], addrBody)
  	msg[4+len(addrBody)] = byte(addrPort >> 8)
  	msg[4+len(addrBody)+1] = byte(addrPort & 0xff)
  
  	// Send the message
  	_, err := w.Write(msg)
  	return err
  }
docs: // sendReply is used to send a reply message